canOpenURL Google maps issue - swift

so today we received a ticket that our application does't open de Google Maps but open another app JabJobs in our application we check if there is GoogleMaps installed as follow:
(UIApplication.shared.canOpenURL(NSURL(string:"comgooglemaps://")! as URL))
so if there is an GoogleMaps installed there is no problem but if we uninstall the GoogleMaps app, and install JabJobs the UIApplication.shared.canOpenURL still return true value and when we go further with
UIApplication.shared.openURL(NSURL(string:
"comgooglemaps://?saddr=&daddr=\(place.lat),\(place.lng)&directionsmode=driving")! as URL)
a system popUp is displayed with "MyApp" wants to open "JabJobs"
Q1. Is that possible that another app to respond to same URL as googleApp ?
Q2. How can i check if there is a GoogleMaps installed if the code above doesn't work?

Of course it's possible, you can respond to any URL scheme if you register app for it.
From https://developers.google.com/maps/documentation/urls/ios-urlscheme, I can see that Google Maps have more url schemes, for example comgooglemapsurl://. You can check if these 2 schemes are available if not then it's probably other App, unless they support all these schemes... then you can't do nothing, but as I can see JabJobs does not support comgooglemapsurl:// scheme.

Related

PWA: prevent urls from opening in the PWA

I've built an angular app using #angular/pwa, that supports external logins like Microsoft, Google, Facebook and Twiitter. When a user wants to signin using an external login, I'm using window.open to open the url hosting the Challenge.
The problem is that when calling window.open from the web app in the browser, the url is being forced to open in the PWA.
I've litterally already tried everything I can to prevent this, but without success. The last thing I've tried was to host my endpoints for my external logins on a subdomain, which worked quite well.
But now I've implemented 2FA in my web app, and for 2FA to work, the ExternalLoginSigninAsync must be called from the same domain as the call to TwoFactorAuthenticatorSignInAsync. So how can I force an url (window.open) to open in the browser instead of the PWA?
PS: Don't come up with
Exclude from navigationUrls ("navigationUrls": [ "!/web/v3/Account/connect/" ])
window.open(url, '_system')
window.open(url, '_blank')
Use ngsw-bypass (window.open(url + '?ngsw-bypass=true'))
That's all been tried, and doesn't work.
Edit
This block of code appears to determine whether the PWA should be launched or a new tab should be opened.
Call stack:
WebappLauncherActivity.shouldLaunchWebapp
WebApkValidator.canWebApkHandleUrl
WebApkValidator.resolveInfosForUrlAndOptionalPackage should return false for the urls you don't want opened in the PWA

Failure to Launch Apps Due to Package Name Inconsistency

When I used huawei AppLinking Service, the app package name is queried to locate the app details page. However, the app package name varies depending on the channel. For example, for a Huawei channel, the package name ends with .huawei, which is different from that in a Google channel.Does this mean it's impossible for an App Linking link to be opened in all local app stores due to package name inconsistency?
Does this mean it's impossible for an App Linking link to be opened in
all local app stores due to package name inconsistency?
The answer is no because there is a solution to this problem.
Perform the following to resolve the issue:
We know that App Linking can redirect users to a custom website if the app has not been installed, so you can use Android intents to create custom links, in which you can configure the package name and fallback URL to be opened. The basic syntax is as follows:
intent:
HOST/URI-path // Optional host
#Intent;
package=[string];
action=[string];
category=[string];
component=[string];
scheme=[string];
S.browser_fallback_url=[encoded_full_url]
end;
Taking advantage of the preceding functions, you can:
Create a link of App Linking and use the setOpenType(CustomUrl) method to set the open type to redirect users to a custom website for the Android platform. The involved APIs are as follows:
.setAndroidLinkInfo(new AppLinking.AndroidLinkInfo.Builder()
.setAndroidDeepLink(Android_LINK)
.setOpenType(CustomUrl)
.setFallbackUrl(BACK_LINK)
.build())
Use an Android intent to configure the preceding custom website. Here, I use Taobao as an example:
"intent://details?id=com.taobao.taobao#Intent;scheme=appmarket;package=com.huawei.appmarket;S.browser_fallback_url=https://play.google.com/store/apps/details?id=com.taobao.taobao;end"
The process is as follows:
1.Use the appmarket scheme to start the app whose package name is com.huawei.appmarket, that is, to open HUAWEI AppGallery.
2.Pass the package name com.taobao.taobao to HUAWEI AppGallery. Then, HUAWEI AppGallery will start this package.
3.If com.huawei.appmarket is not found, set S.browser_fallback_url to a fallback URL.
4.The fallback URL is a Google Play link. Simply set id in this URL to the name of the package to be opened. In this example, the ID is com.taobao.taobao.
Ensure that an App Linking project of the Android platform has been completed. For details, visit:
https://forums.developer.huawei.com/forumPortal/en/topic/0204442462434640048?fid=0101188387844930001
Open the original App Linking project and add the following information in bold:
String BACK_LINK = "intent://details?id=com.taobao.taobao#Intent;" +
"scheme=appmarket;package=com.huawei.appmarket;" +
"S.browser_fallback_url=https://play.google.com/store/apps/details?" +
"id=com.taobao.taobao;end";
AppLinking.Builder builder = new AppLinking.Builder()
.setUriPrefix(DOMAIN_URI_PREFIX)
.setDeepLink(Uri.parse(DEEP_LINK))
.setAndroidLinkInfo(new AppLinking.AndroidLinkInfo.Builder()
.setAndroidDeepLink(Android_DEEP_LINK)
.setOpenType(CustomUrl)
.setFallbackUrl(BACK_LINK)
.build());
Test:
Install the demo on a device, create a link of App Linking, and add it to the note.
Uninstall the app to simulate the scenario where the app is not installed.
For a Huawei phone, tap Open/Download. On AppGallery that is displayed, open the Taobao details page. The following figure shows the Taobao details page in HUAWEI Browser.
For a non-Huawei phone, tap Open/Download. On Google Play that is displayed, open the Taobao details page. The following figure shows the Taobao details page in Google Chrome.
The problem is now resolved. If you encounter a similar problem, simply follow my example step by step and change the package name to resolve the issue.
For more details, please go to:
https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-applinking-introduction?ha_source=hms1

cant understand how to use url-scheme

I made authorization with instagram in safari then opens my redirect-URL: “https://badyi.github.io + code “.
I need to grab redirect-URL. What is url-scheme here?
What is identifier?
What i have to put in info: URL-types?
I know about canOpenUrl method, but idk what to put in info
For example:
bundleID: 999
clientID: G0G
Secret: 666W
redirect_URL : https://badyi.github.io
Upd:
I use oauth2 to use instagram profile data in my ios app.
what I got:
1) the application opens
2) by clicking on the button, opening the safari with the authorization page
3) after logging in, redirect_url opens in safari
I expect that after 3 steps I will be transferred to my application and I will be able to handle my redirect url
Your redirect url has scheme https. It means open "in web", that's why it was handled by Safari
If you want to return to your app after auth, you need to implement your own scheme
Please check documentation about this feature
Option 1: Deeplinks
As #viktor mentioned, you need to implement your own scheme in your application, and set redirect_URL to it.
For example, if you have application named "FooBar", you can make scheme foobar, so the redirect_url can be something like:
foobar://returnFromRedirect?maybeArg=some, then, you need to parse this URL in your application and proceed it properly. Here an article about it
Option 2: Universal Links
You can add trusted domain to your application, so all links from this domain can be opened with your application. Apple documentation

phonegap crossplatform redirection to local file

Hi I'm developing a phonegap + JQueryMobile app, which should be correctly executed on Android, iOs and WindowsPhone as well.
I need to exploit an external service which requires one callback URL to redirect the app to in case of success, and one in case of error (pretty common situation. In my case both will be local files, say www/success.html and www/error.html). Of course I could write different paths for each device (e.g. file:///android_asset/www/success.html on Android), but I'm wondering if the framework provides a more elegant and solution.
So the questions is, how can I get a unique absolute URL which allows me to perform a cross-platform HTTP redirection from a remote web page to a local file within a phonegap application?
Reltive paths should work:
index.html onError -> ./error.html
index.html onSuccess -> ./success.html
Or am I missing a server interaction like:
index.html -> http://someserver.com -> error.html
In this case the serverinterction have to be async.
Use Custom URL Schemes:
How it works: What's a redirect URI? how does it apply to iOS app for OAuth2.0?
PhoneGap and URL Schemes:
http://docs.build.phonegap.com/en_US/3.3.0/configuring_custom_urls.md.html#Custom%20URL%20Schemes
https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin
iOS SDK and Url Schemes
http://code.tutsplus.com/tutorials/ios-sdk-working-with-url-schemes--mobile-6629

Salesforce IOS error requested scope is not available

I have started a new project from salesforce template o XCODE, then I created a fresh remote acces application on Salesforce web.
Then I replaced the RemoteAccessConsumerKey and the OAuthRedirectURI on the AppDelegate.
When I run the application it says, invalid_scope -> requested scope is not available.
my scope params are:
[NSSet setWithObjects:#"visualforce",#"api",nil] ;
What is the callback URL from your Remote Access object?
One guess is that your callback URL begins with something like "https" rather than a custom scheme like "testsfdc" (which is what the template app provides). Try using a custom scheme instead ie "myapp:///mobilesdk/detect/oauth/done"
Just had this on a legacy hybrid app I had to update for iOS10. I noticed that the Salesforce SDK persists its initial oAuth endpoint data. So switching from sandbox to production will return the above error.
Solved by deleting the app completely and compiling with production config.
Hope this helps.