Flutter PWA URL gets truncate in a downloaded PWA (iOS) - ios

I have a PWA deployed on Firebase (which has a unique identifier at the end of the URL) that is working in web browsers mobile/web. When I download this PWA (via Add to Home Screen in Safari on iOS) the unique identifier disappears. It's working fine on Mac and Android but doesn't know why the URL gets truncated (on iOS only).
https://localhost:8080/#/brand/71wh212972g (URL in browser while downloading PWA)
https://localhost:8080/#/brand/ (URL in download PWA on iOS)
I'm not sure what to add or remove from manifest.json to make it work for iOS.

start_url is used to define the launch url after the app is added to the home screen.
{
...
"start_url": "https://<your domain>/#/brand/71wh212972g"
...
}
The start_url member is a string that represents the start URL of the web application — the preferred URL that should be loaded when the user launches the web application (e.g., when the user taps on the web application's icon from a device's application menu or homescreen).
See start_url for details.

Related

Launching an App from Custom URL from Safari not working as intended in iOS >12.3

We share the App deeplinks (Universal links) with our users over email, sometimes they get wrapped by email service providers for safety.
When user taps on these wrapped deeplinks, instead of opening the App directly it opens the url in Safari.
We have a page hosted on that url. We capture the deeplink there and try to open the App using Custom URL scheme (myurlscheme://). But if the App is not installed, we try to redirect the user to the App Store page.
It all worked okay until now, but seems like Apple made some changes in Safari in the new versions of iOS (>12.3).
What’s happening now is, if the App is installed and we open the App from Safari (from Custom URL), the App Store page opens in a split second after opening our App.
This is the Javascript code that we are using:
window.location.href = 'myurlscheme://';
setTimeout(function() {
window.location.href = "https://itunes.apple.com/us/app/myapp/id123456789?ls=1&mt=8";
}, 500);
Is anyone else experiencing this. If yes, were you able to find any solution?
Update:
If we set the timeout to 4000 (i.e. 4 seconds), then it does not redirect to the App Store after launching the App.

Not fully understanding UIApplication.shared.canOpenUrl

Any ideea how is this getting true in
appUrl = "http://dum:site2015#jobz.store.com/
if UIApplication.shared.canOpenURL(appUrl!){
if #available(iOS 10.0, *) {
UIApplication.shared.open(appUrl!)
}
and in url scheme i have jobz-com
the thing is it getting true althought I don't have the app installed ...instead is opening the url in safari... but why is not getting false since i don't have the app installed?
This function does not check for apps installed. It just tells you if it can open that URL, in safari or through an app.
A valid URL will always return true because the system can actually open it somewhere.
According to Apple's own documentation
A URL (Universal Resource Locator). At runtime, the system tests the URL’s scheme to determine if there is an installed app that is registered to handle the scheme. More than one app can be registered to handle a scheme.
https://developer.apple.com/documentation/uikit/uiapplication/1622952-canopenurl
Safari is registered to handle any valid URL, so if the app using the scheme does not exist, the next application registered to read it is safari.
I don't think there's an open API for you to only open an URL if the app is installed.
And always make sure that your URL starts with the scheme you need and not HTTP/S.
my-app://myurl/parameters
Do not use http:// or https:// to open apps. These are for websites. Use app url schemes like this:
jobz-com://
Edit
Another way of doing what the questioner is trying to achieve is to use Universal Link.
Here is the Apple's Official doc about Universal Links and you can follow this medium article which says:
The workaround approach to deep linking with URI schemes involves
using a traditional http:// link to launch a web browser. This link
contains a JavaScript redirect to a custom URI scheme, which is
executed by the web browser to launch the app. If the redirect attempt
fails because the app is not installed, the JavaScript then takes the
user to the App Store or Play Store.
Instead of opening up
Safari first when a link is clicked, iOS will check if a Universal
Link has been registered (an AASA (apple-app-site-association) file
should be there in the domain which contains the bundle id of the app
and the paths the app should open) for the domain associated with the
link, then check if the corresponding app is installed. If the app is
currently installed, it will be opened. If it’s not, Safari will open
and the http(s) link will load.

iOS Custom Url Scheme XCode

First of all, I know how to make custom schemes in iOS and I know how to open my app from a website using a javascript setTimeout method.
I have an app that uses custom URL scheme and it is working great. What it does is, it sends a http://testsite.com/QueryStrings message to other users in the contact list (predefined) and on clicking those web links in the sms, these things happen:
Open the link in Safari
Open the app if installed with custom url using setTimeout
If not installed, move to the normal website page
What I wanted actually is to open my app directly from SMS if installed but for that I have to send my custom url scheme in the SMS, that is not an option because if app is not installed then this SMS wont work so a weblink is the only option for now.
Today, I installed SoundCloud and accidentally noticed this thing is that when http:// m. soundcloud .com /... url is sent in an SMS and on clicking the link it opens the app (if installed) directly not the Safari (Strange for me).
So I was wondering how come their app open from a web link without opening the Safari. I googled it around but I couldn't find a solution to my problem. I am attaching a screenshot too from my mobile where press and hold on the link in the messages app give Open in "SoundCloud" option as well. So how SoundCloud registered a http link to be handled automatically in the app. Please help guys
Screenshot of SoundCloud Open
The answer to this problem is using Associated Domains (But after 9.2 we have to use Universal Links to achieve this).
Before Universal Links, the primary mechanism to open up an app when it was installed was by trying to redirect to an app’s URI scheme (registered in the app’s PLIST like so) in Safari. This put the routing logic in Safari, but there was no way to check if the app was installed or not.
iOS 9 Universal Links were intended to fix this. Instead of opening up Safari first when a link is clicked, iOS will check if a Universal Link has been registered for the domain associated with the link, then check if the corresponding app is installed. If the app is currently installed, it will be opened. If it’s not, Safari will open and the http(s) link will load.
Functionally, it allows you have a single link that will either open your app or open your mobile site.
Configure your app to register approved domains
Registered your app at developers.apple.com
Enable ‘Associated Domains’ on your app identifier
Enable ‘Associated Domain’ on in your Xcode project
Add the proper domain entitlement
Make sure the entitlements file is included at build
Configure your website to host the ‘apple-app-site-association’ file
Buy a domain name or pick from your existing
Acquire SSL certification for the domain name
Create structured ‘apple-app-site-association’ JSON file
Sign the JSON file with the SSL certification
Configure the file server
Apple launched Universal Links in iOS 9.0, which moves the app routing into the OS so that developers don’t need to worry about doing the routing in Javascript.
Receiving Universal Link URL in the App
URI schemes received the deep link URL through openUrl in the App Delegate. Universal Links receive their data via a different code path: continueUserActivity. This new delegate method is used for a number of app transitions, ranging from Spotlight to Universal Links, and will likely see a couple more use cases introduced in future OS versions.
Below is a snippet of code that you can use to retrieve the full Universal Link URL that opened the app.
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler {
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSString *myUrl = [userActivity.webpageURL absoluteString];
// parse URL string or access query params
}
return YES;
}
Source: https://blog.branch.io/how-to-setup-universal-links-to-deep-link-on-apple-ios-9

Grab URL From iOS Safari

My issue is I need to find a way where I can have my action extension run in Safari and open up the website currently being viewed in Safari in my app (my app is a special web browser).
Here's a screenshot:
When the rED extension is clicked, the extension opens up "rED://" which is my custom URL scheme. This launches the app and everything works fine.
However, I want the extension to grab the URL of the webpage being viewed in safari and open that website in my app, so the URL scheme call would look something like "rED://google.com".
What sort of code/methods would I need to implement, and in which .m file would it go in?
Apple provides a method on NSExtensionContext for opening apps via URLs, however that only works for Today extensions (verified by an Apple employee at https://stackoverflow.com/a/24709883/3943258). This technically isn't currently possible.

Facebook App Links Mobile Hosted API doesn' t detect installed app iOS

I am trying to implement Facebook App Links using the Mobile Hosted API. Everything goes smoothly but when I test the App Link URL the app doesn't open even if installed and the URL redirects to the App Store. The custom URL for my app is set properly as when I type the custom scheme inside Safari it does open the app. It seems that something is off but can't tell why.
Here is some data:
The url that I test in the browser is:
http://fb.me/780961121977733
This is the registered data with the Mobile Hosted API:
{
id = 780961121977733;
ios =(
{
"app_name" = GoPhrazy;
"app_store_id" = 903559056;
url = "gophrazy://playerPuzzle/leo3/1420663071896";
}
);
}
The custom url scheme is registered in the info.plist as:
gophrazy://
I thought maybe the app_name case would affect it but I tested that to all lower with no effect.
Anyone has any tips on this?
Thanks
Url scheme in the info.plist MUST be always defined without leading ://

Resources