Open facebook app from cordova/phonegap app - javascript

I'm working on a cordova app.
I'd like to open a facebook page programmatiacally using javascript and I want to open that page using the facebook app (if installed) in the system (Android, iOS).
I tried:
var ID = 1010101010000;
var full_URL = "https://www.facebook.com/pages/page_name/" + ID;
window.open(full_URL, '_system');
window.open('fb:' + full_URL);
window.open('fb:' + 'https://www.facebook.com/' + ID);
window.open('https://www.facebook.com/' + ID, '_system');
but nothing works.
Can you help me?
Thanks
edit:
I tried:
window.open("facebook://pages/" + ID, '_system');
and similars, it just opens the facebook app but it does not redirect to the facebook page I want.

Related

Javascript window pop up and redirect back to homepage (Node.js | react)

I am working on a site where I have used Facebook and google authentication and also oAuth2.0 library. But currently when I click the google or facebook login button then a redirection is happening in same page. But I want something like pinterest, a small pop up window will occur and then after login and token generation the popup will close and the main page will redirect to homepage. How to do so?
Current try:
const googleAuth = () => {
var gWin = window.open(`${process.env.REACT_APP_API_URL}/api/google`, "Google login", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400");
if(gName !== null){
gWin.close();
}
window.location.href = "/courses";
};
window.opener.location.reload();

HTML/PHP Block news tabs on Android and iOS browsers

I use this code for codebar scan with cellphone, on Google Chrome works but on Firefox and Samsung Browser after scan barcode an another tab are created, and +1 tab per scan.
My code:
window.top.location.href = "zxing://scan/?ret=" + href + "profile_sps.php?barid={CODE}";
I tried several ways:
window.open("zxing://scan/?ret=http://rodrigovrodrigues.tk/sjb/profile_sps.php?barid={CODE}", "_top");
window.self.location.href = "zxing://scan/?ret=" + href + "profile_sps.php?barid={CODE}";
window.parent.location.href = "zxing://scan/?ret=" + href + "profile_sps.php?barid={CODE}";
And some others...
Any friend can help me with this?
Thanks for all help.

How to open Linkedin App with Company Page?

It is simple HTML Page and my code is below.
LinkedIn
click on above link in device open LinkedIn app and open company page. This is working fine in IOS devices but not working in Android Devices. Is there any solution for android device? Thanks in Advance
This is the solution. If the user has the linkedin app the app will be launched else the company profile appear in the browser.
String pageId = "your-company-id";
final String urlFb = "linkedin://" + pageId;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(urlFb));
final PackageManager packageManager = this.getPackageManager();
List<ResolveInfo> list = packageManager.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() == 0) {
final String urlBrowser = "http://www.linkedin.com/company/" + pageId;
intent.setData(Uri.parse(urlBrowser));
}
this.startActivity(intent);
For Company Search use :
linkedin://profile/company/{company-name}
I have added
LinkedIn
If linked in App available than open and redirect to company page.
Working fine in Android Device.

Javascript : page loses focus after opening mail client

Help!
I have an iPad app which runs html5 pages... one of the pages requires an email to be sent which opens the Mail program using this code
var link = 'mailto:' + toEmailAdd +'?subject=PDFs&body='+htmlString
window.open(link, 'Mailer');
After I send the email and go back to the program the page has lost focus and has the loading circle running in front of it.
Any help on how to make sure the page doesn't lose focus would be hugely appreciated!
I managed to work this out...
$('#addBtn').bind( "click", function() {
var link = 'mailto:' + toEmailAdd +'?subject=PDFs&body='+htmlString
window.open(link, 'Mailer');
setTimeout(ResetPage, 1);
});
function ResetPage(){
document.location = "";
};

Is there a way to launch a popup for mobile device browser ONLY if App not already installed?

I am looking for a way to launch a popup when a website is viewed via a mobile browser, asking the user if they would like to install our App. But I only want the popup prompt to appear if the App is not already installed.
I have used the following JavaScript (which will work for Apple devices:
<script type="text/javascript">
if( /iPad|iPhone/i.test(navigator.userAgent) ) {
var url=confirm("Would you like to download our mobile application?");
if (url==true)
{
var url = window.location.href = 'http://www.itunes.com';
url.show();
}
else
{
}
}
</script>
As has been discussed here: App notification popup mobile device web browser
However, this popup launches on iOS regardless. I understand you can check for an app url scheme (and so find out if the App is installed) here: How to launch apps (facebook/twitter/etc) from mobile browser but fall back to hyperlink if the app isn't installed
Can I accomplish this by incorporating these two techniques?
You can use this if your app has a custom URL scheme:
<script type="text/javascript">
function startMyApp()
{
document.location = 'appCustomScheme://';
setTimeout( function()
{
if( confirm( 'Install app?'))
{
document.location = 'http://itunes.apple.com/us/app/yourAppId';
}
}, 300);
}
</script>
and call the function startMyApp() on page load, or if you need to bind it to some javascript event (click, etc.).
If you are trying to detect whether twitter or Facebook is installed in your device you can use this in your script.
var url = window.location.href = 'fb://';
for twitter
var url = window.location.href = 'twitter://';
If it does not work, try taking out the //. The above statements will open the twitter or facebook app, you can use that in a if loop or something to detect whether a app is installed on the device.

Categories