How to go into mobile app with gmail template linking - ios

Hi in my project we are using Deep-linking.
when the user tap on email template user needs to go to concern page in mobile app.
by using of template I getting link like this:
TaptoSchedule://host/inner
But backend people are giving link like : https://www.laundry.com/new-schedule/
How to we getting this type of functionalities in iOS please share any idea with me.
I follow this: http://swiftdeveloperblog.com/deep-linking-using-custom-url-scheme/
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
if defaultValues.value(forKey: accessToken) != nil{
let urlPath : String = url.path as String
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
//TaptoSchedule://host/inner
if(urlPath == "/inner"){
let innerPage: PickupController = mainStoryboard.instantiateViewController(withIdentifier: "PickupController") as! PickupController
innerPage.selectedfrom = "Deeplink"
self.window?.rootViewController = innerPage
} else if (urlPath == "/about"){
}
self.window?.makeKeyAndVisible()
return true
}else{
setRootControllerBeforeLogin()
return true
}
}

You have to talk to backend people to call
TaptoSchedule://host/inner
after user visit https://www.laundry.com/new-schedule/ in order to open your app

You probably want to use Universal Links instead of Deep Links. Universal Links use the standard URL format which appears to be what your backend team is providing for you.
From a customer perspective the experience is essentially the same between Deep Links and Universal Links. However, Universal Links give you some additional flexibility. For example, Universal Links use the standard URL format, which can link to a webpage in cases where your user does not have your application installed.
Check out the Apple documentation here for details:
https://developer.apple.com/ios/universal-links/
https://developer.apple.com/documentation/uikit/inter-process_communication/allowing_apps_and_websites_to_link_to_your_content/enabling_universal_links

Related

iOS Action Extension, share PDF from Safari fails

I have an Action Extension to which I'm trying to share PDF-files.
I'm using the boilerplate code for ActionRequestHandler.swift that was autogenerated for me:
func beginRequest(with context: NSExtensionContext) {
// Do not call super in an Action extension with no user interface
self.extensionContext = context
for item in context.inputItems as! [NSExtensionItem] {
if let attachments = item.attachments {
for itemProvider in attachments {
...
...
}
}
}
}
Working from other apps
When exporting from every application except Safari, this is what I get:
This is all ok, I can verify that it's an pdf by checking the com.adobe.pdf and then I use the public.file-url to fetch the shared file.
Failing from Safari
But when exporting from Safari (doesn't matter if I choose "Automatic" or "Pdf" for file type), I instead only get com.apple.property-list:
Further info
Both dropbox and OneDrive works, so it's doable in some sort of way.
Also I realised that sharing an PDF from a url that's protected by some sort of login doesn't work with "Public.file-url" since that URL wont be accessible from inside swift-code.
That leads me to think that the java-script preprocessor might be the way to go? Fetch the pdf-contents with JS and pass it on to code?
Question
How do I use the com.apple.property-list to fetch the file?
Or is some config I did faulty, since I get this property-list instead of the pdf/url combo?
While I didn't manage to figure out a solution to the original question, I did manage to solve the problem.
When adding an Action Extension, one gets to choose Action type:
Presents user interface
No user interface
I choosed No user interfacesince that was what I wanted.
That gave me an Action.js file and ActionRequestHandler.swift:
class ActionRequestHandler: NSObject, NSExtensionRequestHandling {
...
}
These files seem to work around a system where the Action.js is supposed to fetch/manipulate the source page and then send information to the backing Swift code. As stated in my original question, when sharing a PDF from Safari, no PDF-URL gets attached.
A working solution
If I instead choose Presents user interface, I got another setup, ActionViewController.swift:
class ActionViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Get the item[s] we're handling from the extension context.
for item in self.extensionContext!.inputItems as! [NSExtensionItem] {
for provider in item.attachments! {
if provider.hasItemConformingToTypeIdentifier(kUTTypePDF as String) {
provider.loadItem(forTypeIdentifier: kUTTypePDF as String, options: nil, completionHandler: { (pdfUrl, error) in
OperationQueue.main.addOperation {
if let pdfUrl = pdfUrl as? URL {
// pdfUrl now contains the path to the shared pdf data
}
}
}
}
}
This file / solution works as expected, the extensionContext gets populated with one attachment that conforms to kUTTypePDF as expected.
Why this works, while the "no gui"-approach doesn't, I have no idea. Bug or feature?
I have not found any documentation of how/why this is supposed to work in Apple's developer section, the "share extension" documentation is very light.

Send .ovpn profile from iOS app to official openVPN client with url scheme

in my app I have ovpn profile (for example, in Document directory). I'd like to send (share) this file to official client openVPN.
I've implemented this:
let app = UIApplication.shared
var installed: Bool? = nil
if let url = URL(string: "openvpn://") {
installed = app.canOpenURL(url)
}
guard installed ?? false, let url = URL(string: "openvpn://") else {
if let url = URL(string: "https://itunes.apple.com/app/id590379981?mt=8") {
app.open(url)
}
return
}
app.open(url)
And this works great, but I don't know how to improve url scheme and, accordingly, I don't know how to send my file to "Import Profile" screen. Could you share your experience?
Yes, I know about UIActivityViewController
let activityViewController = UIActivityViewController(activityItems: [ovpnUrlPath], applicationActivities: nil)
self.present(activityViewController, animated: true, completion: nil)
but there are additional user's actions, but it's again works great: profile file is opened on "Import Profile" screen as expected:
Question is: how to share my ovpn with url scheme for openVPN?
I've received comment from official openVPN account:
unfortunately, OpenVPN Connect client application doesn't have functionality for sharing connection profiles.
so, right now it's impossible.

How to redirect Universal link to app store without showing pop up on Safari browser?

I am using universal link in iOS application. For the universal link I am using of Firebase dynamic link.
Universal link is working fine when app is installed. But when app is not installed then this link is opening in safari.
I am creating dynamic link (Universal link) programatically in Swift.
func createDynamicLinkForConsumer(){
guard let link = URL(string: "https://<Domain-Name>?consumerID=\(Auth.auth().currentUser?.uid ?? "")&type=consumerReferral") else { return }
let dynamicLinksDomainURIPrefix = "<appName>.page.link"
let linkBuilder = DynamicLinkComponents(link: link, domain: dynamicLinksDomainURIPrefix)
linkBuilder.options?.pathLength = .short
linkBuilder.iOSParameters = DynamicLinkIOSParameters(bundleID: "<Bundle-ID>")
linkBuilder.iOSParameters?.appStoreID = "<app-store-id>"
linkBuilder.androidParameters = DynamicLinkAndroidParameters(packageName: "<android package name>")
linkBuilder.navigationInfoParameters?.isForcedRedirectEnabled = true
guard let longDynamicLink = linkBuilder.url else { return }
print("The long URL is: \(longDynamicLink)")
self.referralLinkLabel.text = String(describing: longDynamicLink)
DynamicLinkComponents.shortenURL(longDynamicLink, options: nil) { (url, warnings, error) in
if url != nil {
print("Short URL is: \(url)")
self.referralLinkLabel.text = String(describing: url!)
}
}
}
This is the screen which opens after when safari opens the link:
After tapping on "Open" button of alert box browser opens app store app.
Actually what I would like to do is to redirect and go to the app store, so users can download the app directly. I don't want to this two steps to open app store.
You should first init DynamicLinkNavigationInfoParameters, then set property to true.
linkBuilder.navigationInfoParameters = DynamicLinkNavigationInfoParameters()
linkBuilder.navigationInfoParameters?.isForcedRedirectEnabled = true
Hi you can reduce these steps with this check on the dynamic link
But you should have in mind that you can have a problem with your link in Messanger app and some other apps.

Unable to post deep link to Facebook via iOS application

I am trying to use the FBSDK, specifically FBSDKShareKit to let users post a deep link to their wall from my app. I have my App set up with Facebook Developers (I know this isn't the issue because my app users sign in with Facebook with no problem) and have a scheme suffix associated with the app.
My application's info.plist has the same suffix set. I know this works because when opening a URL with this suffix from Safari, it navigates to my application.
When opening a URL, my app delegate checks if the URL host matches a certain string, if it does, I then check if the URL path matches a certain string. If both of these match, then I parse the parameters passed from the URL, create a custom object (in this case, an event), instantiate a view controller, and populate that view controller with the custom object's properties.
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
if url.host != "www.mywebsite.app" {
return false
} else if url.path == "/sharedEvent" {
if let parameters = url.queryParameters {
//Get params from url
let name = parameters["name"]!
let description = parameters["description"]!
let lat = parameters["lat"]!.CGFloatValue()
let lng = parameters["lng"]!.CGFloatValue()
let startTime = Int(parameters["startTime"]!)!
let endTime = Int(parameters["endTime"]!)!
let categories = parameters["categories"]!
let priority = Int(parameters["priority"]!)!
let id = parameters["id"]!
let userId = parameters["userId"]!
let userName = parameters["userName"]!
let userEmail = parameters["userEmail"]!
let photoURLs = parameters["photoURLs"]!
let isVerified = Int(parameters["isVerified"]!)
//Create event from parameters
let sharedEvent = Event(name: name, description: description, lat: lat, long: lng, startTime: Date(timeIntervalSince1970: Double(startTime)), endTime: Date(timeIntervalSince1970: Double(endTime)), categories: [categories], priority: priority, id: id, userId: userId, userName: userName, userEmail: userEmail, photoURLs: [photoURLs], isVerified: isVerified!)
//Instantiate eventVC
let storyboard = UIStoryboard(name: "Main", bundle: .main)
let eventVC = storyboard.instantiateViewController(withIdentifier: "EventViewController") as! EventViewController
eventVC.event = sharedEvent
eventVC.userId = userId
eventVC.userEmail = userEmail
eventVC.userName = userName
DispatchQueue.main.async {
self.window!.rootViewController!.presentedViewController?.present(eventVC, animated: true, completion: nil)
}
}
return true
}
This code works as I've tested it by opening a URL from another app with some parameters, and the respective view controller is presented upon the app opening. A URL might look something like this:
fb1068346896678533://www.hootevents.app/sharedEvent?name=Some%20Name&description=Some%20description&lat=38.7016&lng=-90.447&startTime=1548466210&endTime=1551058140&categories=lhw9bs31nr2twlx&priority=1&id=15510581401548012896PfZLZCzDUh&userId=f5qLpyu4XNWa4eJI17sBi71bIw23&userName=David%20Chopin&userEmail=chopindavidg#gmail.com&photoURLs=https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Google_2015_logo.svg/1200px-Google_2015_logo.svg.png&isVerified=1
My issue lies with actually presenting the deep link via Facebook. I've tried two approaches:
Using FBSDKShareKit's FBSDKShareButton by setting the button's shareContent to a FBSDKShareLinkContent with a content url equal to the one shown above. Doing this results in a greyed out, i.e. disabled, FBSDKShareButton. Changing the content's URL to something like "www.google.com" enables the button, meaning that Facebook doesn't like my URL for some reason.
let button = FBSDKShareButton()
let shareContent = FBSDKShareLinkContent()
content.contentURL = URL(string: "fb1068346896678533://www.hootevents.app/sharedEvent?name=Some%20Name&description=Some%20description&lat=38.7016&lng=-90.447&startTime=1548466210&endTime=1551058140&categories=lhw9bs31nr2twlx&priority=1&id=15510581401548012896PfZLZCzDUh&userId=f5qLpyu4XNWa4eJI17sBi71bIw23&userName=David%20Chopin&userEmail=chopindavidg#gmail.com&photoURLs=https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Google_2015_logo.svg/1200px-Google_2015_logo.svg.png&isVerified=1")
button.shareContent = content
Using iOS's Social framework to instantiate an SLComposeViewController, setting said view controller's URL to the same one above, and presenting the view controller. Upon posting through Facebook, I'm prompted with the error message "There was a problem sharing your link." Again, when replacing the URL in question with "www.google.com," the post goes through successfully, indicating, again, that Facebook doesn't like the deep link I'm providing for some reason.
#IBAction func shareButtonPressed(_ sender: Any) {
let vc = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
vc?.add(loadedImages.first?.image)
vc!.add(URL(string: shareURL))
for photo in self.loadedImages {
vc!.add(photo.image!)
}
present(vc!, animated: true, completion: nil)
}
So, in conclusion, I believe that the issue here lies with the fact that Facebook won't allow me to post:
fb1068346896678533://www.hootevents.app/sharedEvent?name=Some%20Name&description=Some%20description&lat=38.7016&lng=-90.447&startTime=1548466210&endTime=1551058140&categories=lhw9bs31nr2twlx&priority=1&id=15510581401548012896PfZLZCzDUh&userId=f5qLpyu4XNWa4eJI17sBi71bIw23&userName=David%20Chopin&userEmail=chopindavidg#gmail.com&photoURLs=https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Google_2015_logo.svg/1200px-Google_2015_logo.svg.png&isVerified=1
on behalf of users. If this is the case, how am I supposed to format my deep link so that users can post it to their wall from my app, effectively sharing events with their Facebook friends and, ideally, driving more traffic to my app?
It seems all I had to do was wait a while (I guess it can take up to 48 hours for the link to start working?).
Note that the Facebook app does not allow users to navigate to another app via universal/deep linking. Their in-app browser is designed to not allow this to happen. There are some workaround, most notably Branch.io, which allows users to get use out of their universal links through Facebook.

open instagram post iPhone hook stopped working

In order to open instagram app with certain post I'm using following code:
func instaOpen(_ postId: String, _ postUrl: String){
let appURL = URL(string: "instagram://media?id=\(postId)")!
if UIApplication.shared.canOpenURL(appURL) {
UIApplication.shared.open(appURL, options: [:], completionHandler: nil)
} else {
// if Instagram app is not installed, open URL inside Safari
let webURL = URL(string: postUrl)!
let svc = SFSafariViewController(url: webURL)
present(svc, animated: true, completion: nil)
}
}
When instaOpen function called – instagram app opens, but login prompt forcefully pops over. Not matter what you do - close it or proceed with login, the queried post simply won't open(see gif).
This started happening recently, after I've updated my app and pushed deployment target to iOS12.
I do have instagram listed in my LSApplicationQueriesSchemes as well as I'm 100% positive that correct mediaID is being passed to instaOpen func (the code worked previously).
Let me know if there's any suggestions on how to fix this and actually open instagram post in instagram app.
Updated - Facebook developer fixed the issue.
Its instagram bug you can follow its progress from https://developers.facebook.com/support/bugs/290173615155052/?disable_redirect=0
Probably a bug, as that feature works on Android.
i manage to "fix" the problem on a pwa app using the Instagram web app.
let appURL = URL(string: "https://www.instagram.com/p/\(postId)")!
//https://www.instagram.com/p/insert here media id

Resources