Handle apple-reference-documentation:// url scheme in web view - swift

I want to show some apple documentation references e.g. NSTableView.
in an app.
I know, NSTableView for example, is located at apple-reference-documentation://hs_JTB0H3I. If I load an URLRequest with such an URL in an WKWebView instance Xcode opens its Documentation Browser and shows the document.
Can someone help me to show the url in my app and not in the Xcode documentation browser.
Code below:
let path = "apple-reference-documentation://hsCsDTDolH"
if let url = URL(string: path) {
let request = URLRequest(url: url)
webView.load(request) // webView is WKWebView
}

No, there is not a way to read the data from Xcode's documentation browser (that would destroy the separation that exists between apps). No, there is not a separate app or tool in Xcode that fetches the docs, it is part of the code within Xcode itself.
apple-reference-documentation:// is a custom URL scheme that Xcode says it can handle (see a brief explanation here). Xcode then uses the rest of the URL to figure out what page to pull from the developer site and display.
In order to hijack this URL scheme you would have to set your app up as capable of handling it, figure out how Xcode determines that hs_JTB0H3I means https://developer.apple.com/documentation/appkit/nstableview, open the correct webpage and then get the system to let your app open the apple-reference-documentation:// links rather than Xcode (there likely isn't an easy way if one exists at all).

Related

Dynamic links / universal links not working in cold start

I use firebase dynamic links. They work perfectly fine when the app is in background and I use the application continue userActivity function.
However if I click on a dynamic link and cold start the application (not running in background) then not only does the application continue userActivity not run, when I breakpoint at didFinishLaunchingWithOptions, I try to print launchOptions and it returns nil.
I setup the dynamic links exactly like the documentation describes.
In the associated domains - I have applinks:*******.page.link and under URL Types I created one with the identifier *******.page.link and the URL scheme as my Bundle identifier.
In didFinishLaunchingWithOptions - before FirebaseApp.configure() , I do (as instructed from a similar question I found about universal linking) FirebaseOptions.defaultOptions()?.deepLinkURLScheme = org.*******.*****
To receive the Firebase Dynamic Links that you created, you must include the Dynamic Links SDK in your app and call the handleUniversalLink: and dynamicLinkFromCustomSchemeURL: methods when your app loads to get the data passed in the Dynamic Link.
Visit for more detail

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);
}
}

How do I know I am being called from a progresive web app?

I've been following the guidance on google to create a PWA, but I am interested if there are any conventions to communicate with your data server that you are being called by a PWA. Is the easiest thing to add a parameter to the request i.e.
var dataUrl = 'https://query.myapi.com/v1/get?source=pwa';
and then check the source parameter? Or should I add to the request header?
In your code
if (window.matchMedia('(display-mode: standalone)').matches) {
// do things here
// set a variable to be used when calling something
// e.g. call Google Analytics to track standalone use
}
** Assumption made that you are also setting up your app to be added to the users home screen as a shortcut
You have to pass in the traffic source to Google Analytics indicating its from PWA. Refer this answer on more details.

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