I'm succesfully using Facebook share method on my webapp like so using the FB JS SDK.
FB.ui({
method: 'share',
href: 'https://myapp.com',
})
However if a user access my webapp using mobile device it requires them to login to facebook through browser even if they have the main facebook app installed on the device. Is it possible to launch share dialog using native facebook app with intent if available and if not fallback to facebook in browser to share.
Facebook has url schemes which have worked in the past on iOS; I don't have a device to test on, but I suspect some of them likely still work.
Similar schemes exist for Android, and just like on iOS, they seem to become disabled and replaced with other tricks / techniques on occasion.
In Javascript, you can check the OS name. I would check for Android or iOS, and then attempt to trigger a url scheme for whichever you find, if either.
in addition to above answer,
chrome 61 onwards you can use share api. This will work same as android intents, with all possible user-installed-native-apps showing in tray, including facebook.
navigator.share({
title,
url,
})
Related
I am working on IOS app in which I open login page in SFSafariViewController. And On that login page when the login is successful, a Json response is generated.
I want to get that response and close SFSafariViewController.
In android I did it through Javascript and Javascript interface..
My server side code for android:
<?php
//curl initialize
//Some code
//Curl Execution
$response = curl_exe($ch)
?>
<script>
showAndroidToast("<?php echo $response;?>");
function showAndroidToast(res){
Android.dataResponse(res);
}
</script>
In android.
Android.dataResponse(res) is my javascript interface which i added to my Chrome Custom Tabs (https://developer.chrome.com/multidevice/android/customtabs).
I want similar functionality for my IOS app.I don't know. Is this possible with SFSafariViewController or not?
According to this StackOverflow answer you cannot download files with SFSafariViewController Furthermore there seems to be no delegate to initiate the download of the JSON according to Apple's documentation
Given this information I am pretty sure that your safest bet is to go the WKWebView route even though WebKit has all sorts of limitations on iOS. You could probably use this as a starting point.
I would personally just call my login API's and create a native login form thus circumventing Apple's browsing options altogether. I hope this helps!
EDIT
The OP is actually using FitBit's API and OAuth2 and according to FitBit's Documentation:
For native applications, this means the authorization page must open in the default browser. Native applications can use custom URL schemes as redirect URIs to redirect the user back from the browser to the application requesting permission. iOS applications may use the SFSafariViewController class instead of app switching to Safari. Use of the WKWebView or UIWebView class is prohibited.
Pointers for using FitBit's Authorization Code Grant Flow can be found in their documentation but there is no proper guide. But OAuthSwift supports FitBit so that is probably the easiest way to implement the login. A discussion about a sample integration can also be found here and here.
I'd like to have a single 'Get App' link that auto-detects the user's device type and browser and directs to the appropriate location (iTunes, Google Play, or website sign-up). I am currently using Onelink.to, but it has the following limitations:
if you're on iOS using a non-Safari browser (like Chrome) you end up looking at a bunch of raw JSON because it doesn't know to launch the App Store app. In this case, I'd prefer to direct to the iTunes website or better yet, deep link into the App Store app.
if using the link on your own site and a user is on a device that redirects to a different page of your own website, it complicates setting up event-based goals in Google Analytics
Are there any good JavaScript solutions that handle the App Store redirect while excluding this action on browsers that don't support the iTunes headers?
Thanks!
You can use javascript navigator.userAgent and parse it to detect the device. Then just generate the link according to it.
Here is an example for ios detection:
Detect if device is iOS
I am using Parse for JavaScript, and is working with the ionic framework within the Intel XDK.
I am trying to incorporate social media login, where users are able to signin using facebook.
I generally know how to navigate this but my main concern is the following:
I am using facebook for javascript where it requires a URL, and when that URL is not accessible it doesn't work. Hence, on an iphone or android I cant use facebook yet.
The specific error I get is the following:
Warning
Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
What have I done as far?
I went over the following guide thoroughly:
http://www.benjamin.my/how-to-set-up-facebook-connect-plugin-and-parse-com-in-ionic-phonegap/
It does mention near the end of the guide that
You may have to add an iOS setting or Android setting too eventually when you deploy to either platform.
and this is the part where I am having issues, and for a while.
I have also looked into:
http://shatter-box.com/knowledgebase/facebook-functions-for-cordova-crosswalk-phongegap/
but I am confused in how I can grab the android hashtag. I am not using eclipse, but working within the xdk.
Is there a method to determine in a web page if the device has a particular app installed?
Depending on what you want to do, there is a way. Check out Launching an app with a custom url scheme.
If you want to get your mobile browsers to download/use your application, you can set it up with a custom url scheme as detailed in that post. From safari, add a link to your app's custom url. If you get an error or aren't redirected when a link is clicked or triggered (which you can check for with a setTimeout()) Then the app is not installed.
I don't know what your use case is, so that's the best I can do.
If you're just trying to promote your app only if it isn't installed, you can add a meta tag to the page:
<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL">
For more information, see Promoting Apps with Smart App Banners on Apple's developer website.
If that's not what you're trying to do, this answer may be helpful.
I want to create a Google Sites script that can detect whether my visitors are using Android or iOS and then redirect them to AppStore or Google Play accordingly.
This will allow me to advertise only one QR code for all devices.
Is there a way to easily set it up and host it on Google Sites?
Well the script needs to inspect the HTTP_USER_AGENT header, and do something like this:
Common link to open iOS, Android and BlackBerry app
Bear in mind that not everyone on an Android-based device has the Google Play store (e.g. Kindle Fire -> Amazon Appstore); unfortunately getting the user to an appropriate app store on Android is tricky because there are many options.