Send URL with iMessage App - ios

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.

Related

how open phonepe or google pay using upi deeplinking in ios using swift

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

Opening up facebook app page when button is pushed. Swift 5

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://"

What is the iOS app URL scheme for Bitmoji app?

I'm trying to open the Bitmoji app from within my own app in iOS using UIApplication.shared.open. When I use just "https://www.bitmoji.com/" URL, the Bitmoji app does not intercept the call and it opens the URL in Safari.
Tried "bitmoji://" as the URL scheme, but this does not work. Then I googled for the bitmoji app URL scheme, but without success. Can somebody help?
You can use bitmoji-sdk://:
guard let url = URL(string: "bitmoji-sdk://") else { return }
UIApplication.shared.open(url)
Taken from AppSight.io

What is the difference between itms-app:// and https:// App Store link

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.

Can a url link be shared from iOS app via FB Messenger without presenting UIActivityViewController dialog and not needing Facebook SDK?

I am wondering if it is possible to share/send a url link and other media from iOS app via Facebook Messenger app without having to open UIActivityViewController's activity sheet first, which in addition shows a number of other apps which can handle the intended data and does not allow to exclude apps only UIActivityTypes. I would like to present a FB Messenger dialog with pre-filled url link immediately after a button tap, so no dialog with multiple other apps.
Facebook documentation suggests we should use FB SDK in such cases: https://developers.facebook.com/docs/sharing/ios#message. But what is beyond me is that iOS seems to have a "native access" to the Messenger app (and other apps), but there is no good API which could facilitate some UI customisation.
Any idea if there is a way to directly open FB Messenger with pre-filled message without needing to present UIActivityViewController's activity sheet or installing FB SDK?
EDIT: Let me clarify, I would like to share a url link or other media, it is not necessary that the message is pre-filled with text.
You can share a link via messenger in this way
let urlStr = String(format: "fb-messenger://share/?link=%#", sharelink!)
let url = NSURL(string: urlStr)
if UIApplication.shared.canOpenURL(url! as URL) {
UIApplication.shared.open(url! as URL, options: [:]) { (success) in
if success {
print("Messenger accessed successfully")
} else {
print("Error accessing Messenger")
}
}
} else {
// show Install Messenger
}
After lots of searching I can confirm that it is not possible to share text or other media via Facebook Messenger without using their FB SDK as they do not provide URL schemes for that.

Resources