Thank you in advanced for giving your valuable time for reading this.
I have tried to implement dynamic link through firebase sdk.
Have gone through provided documents for implementing this by firebase.
Issue I face is when I share dynamic link through application generated using below code
guard let link = URL(string: "\(Constant.dynamicLinkBaseUrl)\(urlPathComponent)/\(encShareDetail ?? "")") else { return }
let dynamicLinksDomainURIPrefix = Constant.DomainURIPrefix
let linkBuilder = DynamicLinkComponents(link: link, domainURIPrefix: dynamicLinksDomainURIPrefix)
linkBuilder?.iOSParameters = DynamicLinkIOSParameters(bundleID: Bundle.main.bundleIdentifier ?? Constant.AppBundleID)
linkBuilder?.navigationInfoParameters?.isForcedRedirectEnabled = true
linkBuilder?.iOSParameters?.fallbackURL = URL(string:Constant.AppStoreFallbackUrl)
linkBuilder?.androidParameters = DynamicLinkAndroidParameters(packageName: Constant.AndroidPackageName)
linkBuilder?.androidParameters?.fallbackURL = URL(string: Constant.AndroidFallbackUrl)
linkBuilder?.shorten() { url, warnings, error in
print("URL :: \(String(describing: url?.absoluteString))\nWarnings :: \(String(describing: warnings?.debugDescription))\nError :: \(String(describing: error?.localizedDescription))")
guard let url = url, error == nil else { return }
print("The short URL is: \(url)")
tabBarControllerObj?.presentDefaultShare(videoURL: url.absoluteString)
}
On taping the generated link in device, my application is launched and it am able to get the generated dynamic link in
scene(_ scene: UIScene, continue userActivity: NSUserActivity)
method, I'm able to get the link with the below code
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL,
let host = url.host else {
return
}
print("URL :: \(url.absoluteString)\nHost :: \(host.debugDescription)")
but not able to get the deep link I have created as when I called the method
DynamicLinks.dynamicLinks().handleUniversalLink(url)
It returns with error as "The operation couldn’t be completed. Universal link URL could not be parsed by Dynamic Links."
Don't found any solution related to this as the same Dynamic link is working fine for Android app.
Please help me as I'm stuck with it for around 4 days.
I was able to solve this issue by adding all my url prefixes to info.plist.
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://<custom domain>/login</string>
<string>https://<custom domain>/</string>
</array>
More details at https://firebase.google.com/docs/dynamic-links/custom-domains#console
Related
I need add card to apple Wallet in Unity.
For example - I am already generated pkpass file (it could storage in resources) and now I need only button in my app, what can added this card to Wallet.
I have read this manual and find only code for swift:
guard let passPath = Bundle.main.path(forResource: "wallet", ofType: "pkpass") else { return }
let error: ErrorPointer = ErrorPointer(nilLiteral: ())
guard let passData = NSData(contentsOfFile: passPath) else { return }
let pass = PKPass(data: passData as Data, error: error)
let passLibrary = PKPassLibrary()
passLibrary.addPasses([pass]) { (status) in
print(passLibrary.containsPass(pass))
}
As I understood, I need implement PKPassLibrary in Unity and add this method (with some modifications) to button click event.
Could you help me with this moment, please?
The situation is difficult by the fact that I don't have a Mac and IOs device.
I'm trying to get Dynamic Links to shorten my URL with the following code:
guard let link = URL(string: "https://myapp.com") else { return }
let dynamicLinksDomainURIPrefix = "https://app.myapp.com/link"
let linkBuilder = DynamicLinkComponents(link: link, domainURIPrefix: dynamicLinksDomainURIPrefix)
linkBuilder?.iOSParameters = DynamicLinkIOSParameters(bundleID: "com.myapp.ios")
guard let longDynamicLink = linkBuilder?.url else { return }
print("The long URL is: \(longDynamicLink)")
let options = DynamicLinkComponentsOptions()
options.pathLength = .short
linkBuilder?.options = options
linkBuilder?.shorten() { url, warnings, error in
guard let url = url, error != nil else { return }
print("The short URL is: \(url)")
}
It's printing the long URL fine, but the line below (for short URL) is never being called:
print("The short URL is: \(url)")
Because url returns nil and I have no idea why. Nothing I've found in the guides or online has lead me in the right direction.
What am I doing wrong??
I think it is because the following is incorrect:
guard let url = url, error != nil else { return }
You are saying make sure there is a non nil URL and make sure there is an error.
I think the Firebase docs are wrong. Instead, you want:
guard let url = url, error == nil else { return }
What you have done here :
linkBuilder?.shorten() { url, warnings, error in
guard let url = url, error != nil else { return }
print("The short URL is: \(url)")
}
is you are unwrapping the url and checking if error contains some Error, then you are printing 'The short URL is: (url)' it means if shorten() succeeds and there's no Error your print method will never be executed.
What you have to do is, First check if error doesn't contain any Error than call print()
linkBuilder?.shorten() { url, warnings, error in
guard error == nil else { return }
if let shortUrl = url {
print("The short url is \(shortUrl)")
}
}
I am using Firebase Dynamic links to send informations via Mail.
The links work when i try to open them when the app is installed.
However they do not work correctly when the app is not installed.
When i open a link when the app is not installed, they open my homepage, more precise the actual link.
My code is here:
static func generateDynamicLinkFromProduct(product: Product, completion: #escaping (URL?) -> Void) {
let domain = "https://my-homepage.com/"
let bundleID = Bundle.main.bundleIdentifier
var package = "my.app.on.android"
let meta = product.metaJson!
guard let link = URL(string: domain + "product=" + meta) else {
completion(nil)
return
}
let dynamicLinksDomainURIPrefix = "https://myapp.page.link"
let linkBuilder = DynamicLinkComponents(link: link, domainURIPrefix: dynamicLinksDomainURIPrefix)
linkBuilder?.iOSParameters = DynamicLinkIOSParameters(bundleID: bundleID!)
linkBuilder?.iOSParameters?.appStoreID = "APP_STORE_ID"
linkBuilder?.navigationInfoParameters = DynamicLinkNavigationInfoParameters()
linkBuilder?.navigationInfoParameters?.isForcedRedirectEnabled = true
linkBuilder?.androidParameters = DynamicLinkAndroidParameters(packageName: package)
let options = DynamicLinkComponentsOptions()
options.pathLength = .short
linkBuilder?.options = options
let longLink = linkBuilder?.url
print(longLink)
linkBuilder?.shorten() { url, warnings, error in
print(url)
if (error == nil) {
completion(url)
} else {
completion(nil)
}
}
}
(domain, bundle,package and prefix are replaced by the data of the actual app)
The dynamic link opens the actual content of link, i.e. it opens https//my-homepage.com/product=
the output of the debug shows this:
€dit:
The generated long link contains isi and ibi parameters
Check your appStoreId.
I had the same problem and it turned out I switched my developer team ID with the appStoreId of my application.
When I try to share an image to instagram stories I'm getting the following error:
This app is not allowed to query for scheme instagram-stories
Though I added the custom URL scheme instagram-stories to LSApplicationQueriesSchemes
I followed the Instagram's documentation: https://developers.facebook.com/docs/instagram/sharing-to-stories/#ios-developers and my code is as follows:
private func shareToInstagramStories() {
guard let imagePNGData = UIImage(named: "myImage").pngData() else { return }
guard let instagramStoryUrl = URL(string: "instagram-stories://share") else { return }
guard UIApplication.shared.canOpenURL(instagramStoryUrl) else { return }
let itemsToShare: [[String: Any]] = [["com.instagram.sharedSticker.backgroundImage": imagePNGData]]
let pasteboardOptions: [UIPasteboard.OptionsKey: Any] = [.expirationDate: Date().addingTimeInterval(60 * 5)]
UIPasteboard.general.setItems(itemsToShare, options: pasteboardOptions)
UIApplication.shared.open(instagramStoryUrl, options: [:], completionHandler: nil)
}
What should I for not getting the error?
Try to put only <string>instagram</string>. It's not necessary the full path but the base of the scheme url.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>instagram</string>
</array>
Okay I solved the error with the following answer: https://stackoverflow.com/a/38393379/5061249
I was also trying to define LSApplicationQueriesSchemes as a dict :(
let url = URL(string: (pinsFIREBASE[marker.snippet!]?.imageURL)!)
let task = URLSession.shared.dataTask(with: url!) { data, response, error in
guard let data = data, error == nil else { return }
DispatchQueue.main.async() {
self.postImage.image = UIImage(data: data)
}
}
task.resume()
I have the following code that takes a url from firebase, in the form http://i.imgur.com/nkomPpP.jpg, and is supposed to turn that url into a UIImage that can be placed on a view. However, while extracting the text from the firebase object works, parsing the image URL doesn't seem to be working as I get an empty view. What am I doing wrong?
I know why, your code works. The problem is your image link. Your imageURL's HTTP type. iOS don't like HTTP type request because it's not safe.
Plan A: Try a HTTPS type image link, it works.
Plan B: Add "App Transport Security Settings" in project info ,and set "Allow
Arbitrary Loads" yes in "App Transport Security Settings" dictionary.
I suggested use Plan A, that's Apple want iOSDev to do.
You need to remove the () from after DispatchQueue.main.async(). Try this:
let url = URL(string: (pinsFIREBASE[marker.snippet!]?.imageURL)!)
let task = URLSession.shared.dataTask(with: url!) { data, response, error in
guard let data = data, error == nil else { return }
DispatchQueue.main.async {
self.postImage.image = UIImage(data: data)
}
}
task.resume()