I'm new to this FB deep linking and followed all the steps mentioned in the documentation https://developers.facebook.com/docs/ios/deep-linking/ However, when I send the test deeplink from FB Ads console, clicking on the Ads opens the app page on AppStore instead of opening my app. Please help.
expected results:- launch the app
I tried all the forums mentioned in the developer documentation
I use this piece of code:
let svcWWW : NSURL = NSURL(string: "https://www.facebook.com/radioNED/")!
let svcFB : NSURL = NSURL(string: "fb://profile/1238133072954301/")!
if (UIApplication.shared.canOpenURL(svcFB as URL)) {
UIApplication.shared.open(svcFB as URL, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
} else {
UIApplication.shared.open(svcWWW as URL, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
}
It opens the Facebook app if available. Otherwise it will open Safari en load the Facebook webpage.
I hope this helps you out ;)
Related
Im trying to integrate UPI payment in my app. i have seen some apps where they are providing google pay and phone pe buttons, if they are installed in the device. on clicking button, particular app is opening.
I need to implement similar experience in my ios app.
i have tried generating URL as specified in NPCI doc https://www.npci.org.in/sites/all/themes/npcl/images/PDF/UPI_Linking_Specs_ver_1.5.1.pdf
i tried using UIApplication.shared.open(url, options: [:], completionHandler to open the UPI app. every time its opening whatsapp only.
How can we open phone pe / google pay app based on users selection without entering payer's UPI id.
It is opening WhatsApp because Generic Intent does not work on iOS.
For Gpay you could try below codes:
#IBAction func Gpay(sender: AnyObject) {
guard let url = NSURL(string: "tez://upi/pay?pa=test#dcb&cu=INR&mc=0000&appName=TEST&tn=To&am=1.0&pn=TEST&tr=TEST-1574159602900") else {
return
}
UIApplication.shared.open(url as URL)
}
You can get deeplink url of PhonePe as below
PhonePeSDK.shared().deeplinkUrl
I would like to deeplink to my xing profile within my application.
I know how to open the iOS Xing App in my code, but I can't figure out how to deeplink to my own profile for example.
Does anyone know the URL route?
let appScheme = "Xing://profile/[username]"
let appSchemeURL = URL(string: appScheme)
if UIApplication.shared.canOpenURL(appSchemeURL!) {
UIApplication.shared.open(appSchemeURL!, options: [:], completionHandler: nil)
}
That's how I tried it, but all it does is, it opens the app on the initial screen.
The app scheme has to be either xing://profiles/[username] or xing://profiles/[userId]. Then it should work.
Facebook app wont open up, facebook in safari opens instead. Using xCode 10.2.1
Deployment target running iOS 12.2
Edit: this code does achieve the desired objective for Instagram
Edit2: So on #bbrodsky's recommendation i changed "facebook" to "fb" in the URL link. The problem now is that it opens to my personal feed and not the business page i want it to open to.
Edit3: So ive gotten it to work. Opens up the facebook app, and goes to desired page. Had to change the appURL to "fb://profile/NUMERICFBID". I was able to get the numeric facebook ID for the page at this site https://findmyfbid.com/
Tried solutions from this post and others. Cant seem to find any recent answers to this question, as everything seems to be from earlier versions of iOS and swift/xCode. Unsure if things have changed. Have added the recommended code to the plist source file with no results.
How to open fb and instagram app by tapping on button in Swift
#IBAction func facebookButtonTapped(_ sender: UIButton) {
let screenName = "MYSCREENNAME"
let appURL = NSURL(string: "facebook://user?screen_name=\
(screenName)")!
let webURL = NSURL(string: "https://facebook.com/\
(screenName)")!
if UIApplication.shared.canOpenURL(appURL as URL) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(appURL as URL, options:
[:], completionHandler: nil)
}
else { UIApplication.shared.openURL(appURL as URL)
}
}
else {
//redirect to safari because the user doesn't have
Instagram
if #available(iOS 10.0, *) {
UIApplication.shared.open(webURL as URL, options:
[:], completionHandler: nil)
}
else {UIApplication.shared.openURL(webURL as URL)
}
}
expected result is that the facebook app opens to the particular page. keep getting this error code.
2019-06-08 11:28:39.561051-0500 SocialMediaLinkPractice[9888:2173963] -canOpenURL: failed for URL: "facebook://user?screen_name=MYSCREENNAME" - error: "This app is not allowed to query for scheme facebook"
Add in Info.plist
First, you have to modify Info.plist to list instagram and facebook with LSApplicationQueriesSchemes. Simply open Info.plist as a Source Code, and paste this:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>instagram</string>
<string>fb</string>
</array>
When you want to open the Facebook App and direct to a Facebook-Page, use the Page-ID. Here is a Link, where you could find them: https://www.facebook.com/help/1503421039731588
Schemes
fb://profile – Open Facebook app to the user’s profile OR pages
fb://friends – Open Facebook app to the friends list
fb://notifications – Open Facebook app to the notifications list (NOTE: there appears to be a bug with this URL. The Notifications page opens. However, it’s not possible to navigate to anywhere else in the Facebook app)
fb://feed – Open Facebook app to the News Feed
fb://events – Open Facebook app to the Events page
fb://requests – Open Facebook app to the Requests list
fb://notes – Open Facebook app to the Notes page
fb://albums – Open Facebook app to Photo Albums list
Source: https://stackoverflow.com/a/10416399/8642838
SwiftUI-Code Version
Button(action: {
let url = URL(string: "fb://profile/<PAGE_ID>")!
let application = UIApplication.shared
// Check if the facebook App is installed
if application.canOpenURL(url) {
application.open(url)
} else {
// If Facebook App is not installed, open Safari with Facebook Link
application.open(URL(string: "https://de-de.facebook.com/apple")!)
}
}, label: {
Text("Facebook")
})
if you want to open a specific profile on Facebook app, you have to use
let username = "your Facebook name"
let appURL = URL(string: "fb://profile/\(username)/?id=\(username)")!
otherwise it will not work.
I believe you want to use "fb://" and not "facebook://"
I'm trying to create the link to App Store and I found many ways to do it.
Open App Store page in iTunes Store.
let url = URL(string: "itms://itunes.apple.com/th/app/cafe-amazon-smart-pay/id1047593542")
Open App Store.
let url = URL(string: "https://itunes.apple.com/th/app/cafe-amazon-smart-pay/id1047593542")
Open App Store.
let url = URL(string: "itms-apps://itunes.apple.com/th/app/cafe-amazon-smart-pay/id1047593542?mt=8")
As far as I know, Method #2 and #3 almost produce the same result.
But I curious it should have some difference?.
if you have using this link itms-app:// it will open the app directly in the store.
let url = URL(string: "itms://itunes.apple.com/th/app/cafe-amazon-smart-pay/id1047593542")
you have using this link https:// it will open links from launching iTunes with Safari.
var iTunesLink = "https://itunes.apple.com/th/app/cafe-amazon-smart-pay/id1047593542"
UIApplication.shared.openURL(URL(string: iTunesLink)!)
First of all itms and itms-apps are defined Apple URL Schemes and they are only linked immediately to their specific app as you said itms will open iTunes Store and itms-apps will open the App Store.(if they exist)
if #available(iOS 10.0, *) {
UIApplication.shared.open(url!, options: [:]) { (finished) in
}
} else {
// Fallback on earlier versions
UIApplication.shared.openURL(url!)
}
Using https if used with openURL or open will launch the App Store if exist or iOS supported otherwise it will launch Safari.
Option 2 depends on JavaScript. If you load https://itunes.apple.com/th/app/cafe-amazon-smart-pay/id1047593542 in the browser with JavaScript disabled, the App Store won't open.
I would like to send a link with my message to allow the user to open the app store to install the app or use a deep link to link into a certain piece of content in my app, similar to the Apple Music iMessage App. I am currently using:
var messagee:MSMessage = message.url = URL(string: "https://itunes.apple.com/us/app/reaction-timer-game/id572319874?ls=1&mt=8")
template.image = game1Image.image!
template.imageTitle = "Game 1"
template.imageSubtitle = "\(bestScore1[0])"
But when I tap on the the image the iMessage app opens instead of the URL. Is this possible and if so, how can I do this?
Should I be sending the URL with this:
let url = URL(string: "urlData")
self.activeConversation?.insertAttachment(url!, withAlternateFilename: "URL", completionHandler: { (error) in
if error != nil {
print("Error")
} else {
print("Sent")
}
})
Thank you
I don't think that's possible. If you try to open any URL or a URL scheme, it will open your main iOS app if you have one.
In my case I wanted to display a web page so what I did is just use a UIWebView instead of opening Safari directly.
iMessage will already display your app link if the recipient doesn't have it installed. This helps app discoverability but you can't automatically open your app in the App Store.