iOS - Make WhatsApp voice/video call programmatically from my application - ios

I have a requirement to make WhatsApp calls from my application. When I click the mobile number in my app then it should redirect to WhatsApp and initiate voice/video calls without user intervention.
I've found a solution from the below link but it's opening application and landing on user chat window.
https://faq.whatsapp.com/en/iphone/23559013

There isn't an api for that. Whatsapp only allows interactions like sharing media such as video, audio and images as mentioned in the FAQ. I tried searching for official developer doc for one of my requirements but, was unsuccessful the FAQ seems to be the only official doc availabe:
If your application creates photos, videos, or audio notes and you'd like your users to share these media using WhatsApp, you can use the Document Interaction API to send your media to your WhatsApp contacts and groups.
The only thing you could do is open the contact page for the user. And then he has to call by manually clicking on call button. Maybe, give an info that suggests user to do so.
if #available(iOS 10.0, *) {
UIApplication.shared.open(NSURL(string: "whatsapp://send?phone=+91phonenumber")! as URL)
} else {
UIApplication.shared.openURL(NSURL(string: "whatsapp://send?phone=+91phonenumber")! as URL)
}

Related

Redirects to app store if app is not installed

Scenario is user will get a link to his email. If user clicks on the link, If app is already installed, app should open and if app is not installed it should redirect to app store.
I've seen deeplinks implementation, but I believe it needs some more implementation in backend too. Can any one help on this?
Redirect to application if installed, otherwise to App Store
gone through this. Is there any better way?
added gif for one more scenario:
in the below gif, from email to app it navigates directly? how?
I'm assuming the link you want to pass by email is an https link. If that's the case, for iOS to be able to redirect it to your app, you'll need to implement universal links. This implementation requires you to register the domain you want to respond to on your entitlements file and add an apple-app-site-association file to your backend. This way Apple can verify the domain you're trying to respond to is really yours.
As a result, when the app gets installed, it can be invoked by your domain links via deeplinking.
Now when there's no installed app able to respond to a specific https domain link, the system will simply open it on a web browser. Consequently, you cannot force iOS to open such links on AppStore directly. What you can do is to check whether the running device is iOS when your website gets accessed and ask the system to show your app on AppStore.
And to request iOS to launch AppStore from a website you can use itms-apps:
const iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
if (iOS) {
// Just replace `https://` with `itms://` on your app's AppStore link.
window.location.href = "itms://itunes.apple.com/us/app/google-maps-transit-food/id585027354?mt=8";
}
// In this example I'm redirecting to Google Maps app page on AppStore.
Note: This is just a simple example used to demonstrate the concept. For a real application, you may want to use a device detection library for browsers, like mobile-detect.js
My suggestion is check iOS version
here Example
let url = URL(string: "www.stackoverflow.com")!
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}

Instagram - share image, text and url via iOS app : swift

I am trying to share image with some text and a url from my app to Instagram which would later redirect to iOS app installed on the phone from Instagram app. I am able to share image on instagram but not with text and url. Any help related to the same would be great!
A Bit Late To Answer (Aug, 2022)
I have successfully cracked the plain text sharing on Instagram by myself, after doing a lot of research on google on this topic. You can use the mentioned deep link to open Instagram Direct with some text to share from your application,
instagram://sharesheet?text={AnyTextOrLinkToShare}
Moreover, the below code should work on iOS to launch Instagram Direct (Messenger) from your app with some content
if let url = URL(string: "instagram://sharesheet?text=https://google.com/") {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
Not sure, why did they hide this information from their official documentation but now who cares, I have achieved it with the continuous efforts of 16-18 hrs! :)
Instagram had removed pushing custom captions to their app while sharing photos at one point, check this post.
I also understand, according to the Instagram iPhone Hooks page, that you can pass a photo only to the "Select A Filter" Instagram screen, which is before you set a caption. I'm sorry, but I don't think Instagram supports custom captions.
Looks like there is not official way to share image/sticker together with a text/link to Instagram - because "com.instagram.sharedSticker.contentURL" parameter bacame unavailable or private.
But there is one workaround how to proceed working with image/sticker & text/url consequentially described here: https://stackoverflow.com/a/74241318/20343737

Deeplink into Spotify Search on iOS from Native App

I have an application in the Apple app store that streams a live radio station and provides a list of tracks that have been played. The user can navigate to specific track in that list, tap a Spotify button and the user is directed into Spotify via Deeplinking, using the Spotify search route (example below):
spotify://search/artistName
This feature was working great (about 85% accuracy search on artist name) until recently. Spotify opens, but I receive a native alert:
Couldn't Open Link
Spotify can't open this type of link on this device.
Did the search route change?
Did Spotify disable this feature?
Removing the // from the URL works for me: spotify:search:artistName. Example in Swift:
UIApplication.shared.open(URL(string: "spotify:search:pink+floyd")!, options: [:], completionHandler: nil)

Url scheme for making WhatsApp call programmatically from iOS app (voice call VOIP)?

I have referred How can I place a WhatsApp call from an iOS app? which states that this feature is currently not available in iOS and as per WhatsApp FAQ Share Extension (Custom URL Scheme) it has still not mentioned any schema for placing a call, document it has mentioned:
Placing a WhatsApp call(voice call VOIP)
To make a WhatsApp call, simply open the chat with the person you want to call and tap Call in the top right corner.
Whatsapp FAQ Here
But placing a WhatsApp call from android is possible, Which I could not find in iOS.But placing WhatsApp call feature is available from phone contacts.
So my doubt is whether it is currently available in iOS to place a WhatsApp (voip)voice call from my iOS app?
If possible can you please suggest me with url schema(if available) for this just like place a chat from my app like this #"whatsapp://send?text=Hello%2C%20World!" as I couldn't find this?
I have google it and searched a lot on stackoverflow and https://faq.whatsapp.com
Seems like currently, video call from contact book feature is limited to OS level only.
But you can open particular contact then user has to manually tap on video call button.
This is regardless of phone no is stored in contact book or not. ( You can directly open )
I have tried this in Swift 3 code.
if #available(iOS 10.0, *) {
UIApplication.shared.open(NSURL(string: "whatsapp://send?phone=+91phonenumber")! as URL)
} else {
UIApplication.shared.openURL(NSURL(string: "whatsapp://send?phone=+91phonenumber")! as URL)
}
https://faq.whatsapp.com/en/iphone/23559013
Hope this helps you to figure out further way

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