phonegap crossplatform redirection to local file - redirect

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

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

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

canOpenURL Google maps issue

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.

visitor id mid is not consistent across domains when i login from app and then from moving from app to web

Experience cloud vistor id is used. App, web are using same adobe launch library. When I login into app url change and mid changes and then if I navigate from app to web responsive page mid is changed and I am not seeing any cross-domain pathing report from app to web ?
anything do I need to do with s.cookiedomainperiod or anything to make this work?
The Experience Cloud Visitor ID is not automatically carried over from the native mobile app to a (mobile) web page. The long story short is native apps don't really store data locally in the same way as web browsers, so there's no automatic ability to use the same local storage mechanism/source between the two.
In order to do this, you must add some code to the mobile app to append the mid value to the target URL, e.g. :
Android
String urlString = "http://www.example.com/index.php";
String urlStringWithVisitorData = Visitor.appendToURL(urlString);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlStringWithVisitorData));
startActivity(browserIntent);
iOS
NSURL *url = [NSURL URLWithString:#”http://www.example.com/index.php"];
NSURL *urlWithVisitorData = [ADBMobile visitorAppendToURL:url];
[[UIApplication sharedApplication] openURL:urlWithVisitorData];
If implemented properly, you should now see a adobe_mc= parameter appended to the target URL. Then on page view of the target page, if you have the Adobe Analytics javascript and Experience Cloud Visitor ID libraries implemented, they will automatically look for and use that value instead of generate a new value (should not require any config / coding on this end).
Update:
#Ramaiyavraghvendra you made a comment:
Hi #Crayon, mny thanks for your profound answer. I am sorry that i
missed to inform that this app is not native one but this is a SPA
app. so the implementation of entire app is also done through launch.
Could you pl help in this case then.
I'm not entirely sure I understand your issue. If you are NOT moving from a native mobile app to web page, and your mobile app is really a web based SPA that outputs Launch as regular javascript code throughout the entire app, then you shouldn't have to do anything; the Experience Cloud ID service should carry over the id from page to page.
So it sounds to me like perhaps your Experience Cloud Visitor ID and/or Adobe Analytics collection server settings are not configured correctly. the cookie domain period variables may be an issue, if logging in involves moving from say www.mysite.com to www.mysite.co.uk or similar, but shouldn't be a problem if the TLD has the same # of periods.
Or, the trackingServer and trackingServerSecure variables may not be configured properly. In practice, I usually do not set trackingServerSecure at all. These variables get kind of confusing and IMO buggy in different scenarios vs. what you are using, so I tend to use the "secure" value in the trackingServer field and leave the trackingServerSecure blank, and then Experience Cloud Visitor ID and Adobe Analytics will just use the secure version 100% of the time.
Or..it could be a number of other config variables not properly set. It's hard to say if any of this is off, without access to the app and Launch container.
Also you may want to check the response headers for your logged in pages. It may be that they are configured to reject certain existing non-https cookies or something else that effectively causes the existing cookies to be unreadable and make the Experience Cloud ID service generate a new ID and cookies.
Or.. maybe your app kind of is a native mobile app but using an http wrapper to pull in web pages, so it is basically a web browser but it is effectively like moving from one web browser to another (e.g. starting on www.site.com/pageA on Chrome, and then copy/pasting that URL over to Internet Explorer to view). So effectively, different cookie jar.
Launch (or DTM) + Experience Cloud ID (Javascript methods)
In cases such as the last 2 paragraphs, you have to decorate your target links the same as my original answer, but using the Launch + Experience Cloud ID Service javascript syntax:
_satellite.getVisitorId().appendVisitorIDsTo('[your url here]');
You write some code to get the target URL of the link. Then run it through this code to return the url with the parameters added to them, and then you update your link with the new URL.
Super generic example that just updates all links on the page. In practice, you should only do this for relevant link(s) the visitor is redirected to.
var urls = document.querySelectorAll('a');
for (var i = 0, l = urls.length; i < l; i++) {
if (urls[i].href) {
urls[i].href = _satellite.getVisitorId().appendVisitorIDsTo(urls[i].href);
}
}

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.