The ShortcutLinks(action:) method of AppIntents opens the app's shortcut folder in the iOS Shortcuts app. I'd like to replicate the same behavior using a standard button. Something like this:
Button {
// Deeplink to the shortcuts app here
} label: {
Text("Open shortcut app")
}
According to the Apple documentation, you can use openURL(URL(string: "shortcuts://open-shortcut?name=save%20file")!) to open a specific action. Which works as advertised for the top level actions and Starter Shortcuts actions.
However, it doesn't work for any of the actions included in apps, for example:
openURL(URL(string: "shortcuts://open-shortcut?name=buffer")!) // "File not found" error
And what I'm trying to achieve is something slightly different: to open the app's folder (like ShortcutLinks(action:) does)
I've tried a few different URLs:
openURL(URL(string: "shortcuts://shortcuts/Buffer")!) // "Shortcut not found" error
openURL(URL(string: "shortcuts://shortcuts/app%20shortcuts/Buffer")!) // "Shortcut not found" error
None seem to work.
I guess the question is: what is the deeplink/URL ShortcutLinks(action:) uses?
Related
I am trying to load a URL in react native webview which needs credentials. Normally when we open this URL in a browser like Safari and Chrome, it give us a popup to enter the credentials. Not sure how to handle it in React-Native?
We require LinkedIn authentication for our React Native application, we couldn't find a way to work with the WebView component.
This may very well be possible, however, I will highlight what solution we came up with. These steps are for an iOS React Native app, steps will differ for Android but the concept is the same. This also does require some server configuration.
We created a URL Type. In XCode, select your project and click on the Info tab. Scroll to the bottom to see URL Types. Fill in the identifier and URL Schemes. Remember what you've set for the URL Schemes. For this example, we will use myscheme.
When the app opens, we use Linking to open up the URL in Safari.
Linking.openURL('https://foo.bar');
The User could then log in via the website, once logged in, you can redirect your User back to.
myscheme://name=Dan
The myscheme matching the URL Scheme you entered within Xcode. As long as you have your application installed and the scheme matches then your app will open.
You can add any payload of information after ://.
In your React application, you can register
componentWillMount() {
Linking.addEventListener('url', this.handleOpenURL);
}
componentWillUnmount() {
Linking.removeEventListener('url', this.handleOpenURL);
}
handleOpenURL = (event) => {
const { url } = event;
if (url.startsWith('myscheme://')) {
// do something with your data.
}
};
I've found two options to open my app from a Safari web page: a custom URL scheme created in my app project's Info.plist or Apple's Universal Linking. Obviously the custom URL scheme is the easiest one to set up, but the problem I'm having with this is that Safari shows a confirmation window asking "Open myapp?" first and the user has to tap OK before the app actually opens. I want my app to open automatically as the scheme is opened, and I'm being told the only way to do this is through Universal Linking (please correct me if this is not true). If this is true, however, I would like to know if it's possible in any way to put the required apple-app-site-association file on a http:// domain instead of https://? According the official Apple documentation the format of a correct Universal Link starts explicitly with https:// but my domain name can't be loaded on https:// without redirecting a few times and that messes up the web services I've written to execute other tasks in my app. The two main questions I'm left with after this issue:
1) Is it really impossible to work around the confirmation prompt using a custom URL scheme (myscheme://)? If it's not impossible, how can I do this?
2) If I have to use Apple Universal Linking, can I use a http:// domain? If so, how do I do it? Right now if I load up the universal link, it just shows the dictionary inside the apple-app-site-association file, which I'm pretty sure is not supposed to happen. I'm told it's supposed to send a NSUserActivity object to my app delegate. How can I accomplish this with a http:// link?
It is not possible to trigger a custom URI scheme without showing an alert to the user. This used to be possible in iOS 8, but iOS 9 started showing the alert for all apps. And iOS 10.3 has extended that even to the App Store itself. You cannot bypass this. Universal Links were created to replace URI schemes for this behavior, so you do need to use them instead.
From your description, I believe you may be misunderstanding how Universal Links work. To answer the literal questions you asked first, no the Universal Link URL itself does not need to be on the https:// protocol, and yes, the apple-app-site-association must be served over https:// without redirects.
However, it sounds like you're trying to serve the content of the apple-app-site-association file for every Universal Link. That is not the correct implementation — the AASA file is hosted only at https://example.com/apple-app-site-association, and iOS automatically retrieves it when the app is installed. After that, any URL on example.com that matches the criteria in the AASA file will be eligible for Universal Links.
All of that said, you really don't want to built out this system on your own. I suggest looking into Firebase Dynamic Links or Branch.io (full disclosure: I'm on the Branch team).
Is it really impossible to work around the confirmation prompt using a custom URL scheme (myscheme://)? If it's not impossible, how can I do this?
That is possible with some hacky tricks and BAD user experience. It requires user to press "add to home screen" button, so I don't recommend this solution in most cases.
set your app scheme like myapp
create the following html file and put it into the web
window.onload = function() {
if (("standalone" in window.navigator) && window.navigator.standalone) {
window.location.href = 'myapp://open'
}
}
open the html file with safari and "add to home screen"
open the home screen icon and your native app will launch
The point is the meta tag.
<meta name="apple-mobile-web-app-capable" content="yes" />
Without this, safari will launch and confirmation prompt will appear.
I added a url scheme newConversation to my info.plist so that when a user clicks on a link in a browser/email it will redirect him to the app. This works perfectly fine.
I was wondering how I can open the app to a specific view controller when clicking this url?
I tried using:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
if ([url.scheme isEqualToString:#"newConversation"]) {
NSLog(#"url schemeeeee");
emailLink = YES;
[self initWindow];
}
return YES;
}
but not getting anywhere with that.
Thanks!
Your app should only have one scheme (such as myappscheme) registered for your app. Then if you need to handle different actions, you provide more specific URLs with that scheme:
myappscheme:///newConversation
myappscheme:///doSomethingElse
Then you get /newConversation for the URL's path. Then your code becomes:
if ([url.path isEqualToString:#"/newConversation"]) {
} else if ([url.path isEqualToString:#"/doSomethingElse"]) {
}
To be honest, this is kind of a pain to implement on your own. A basic custom URL scheme link isn't an ideal solution and has a ton of nasty edge cases, most notably the 'Cannot Open Page" error users will see before if they don't have your app installed, and the fact that many apps actually don't recognize custom scheme URLs as 'clickable' (they just show up as regular text).
A somewhat better approach is to use a regular http:// link, and then redirect the visitor to your app — if they have it installed — or to a fallback URL/App Store page. Until iOS 9, a reasonable basic implementation was a JavaScript redirect like this:
setTimeout(function() {
window.location = "https://itunes.apple.com/path/to/your/app/";
}, 25);
// If "yourapp://" is registered, the user will see a dialog
// asking if want to open your app. If they agree, your app will
// launch immediately and the timer won't fire.
// If not installed, you'll get an ugly "Cannot Open Page"
// dialogue and the App Store will launch when the timer expires.
window.location = "yourapp://";
Unfortunately this would still show a 'Cannot Open Page' error, but until recently it was possible to get around this in a reasonably user-friendly way by using a more nuanced version of this script. Sadly, Apple intentionally broke that with the iOS 9.2 update, so custom URL schemes are actually pretty much useless for deep linking now, unless you are certain the app is already installed on that device.
The best solution is a combination of custom URL scheme links (with intelligent JavaScript redirections) and Apple's new Universal Links. Universal Links let you use a normal http:// URL to a page on your website (the page could be a simple redirection to the App Store without the custom URL trigger that causes the 'Cannot Open Page' error), which is intercepted by your phone and sent directly into your app if installed. Unfortunately Universal Links only work in iOS 9+, and don't work yet when opened inside a lot of apps.
This is quite a lot to handle, so the best option might be a free service like Branch.io (full disclosure: I work with the team) to take care of all the technical aspects.
I'm looking for a way to uncover directory paths in an iOS app, for the purposes of deep linking.
Right now, I know that I can unpack an app's info.plist file and look for the "CFBundleURLScheme." This parameter usually looks like this:
CFBundleURLTypes = (
{ CFBundleURLName = "BUNDLEID";
CFBundleURLSchemes = ( "scheme", "fb1234567891011" );
},
);
From here, I can construct a basic URL scheme to launch the app to the home page, by appending "://" to the end of one of the "CFBundleURLSchemes."
If I enter scheme://
into Safari's URL bar and hit enter, then the app will launch on my iPhone to the app's homepage.
However, there is another deep link I know works - scheme://upgrade/pro- This links to a specific in-app directory, and when launched in Safari, opens the app directly to the upgrade page.
I want to be able to find a list of in-app directories that I can append to the basic URL scheme to be able to link to actual in-app pages.
Is there a file somewhere in an app's bundle or Payload folder that has a list of defined directory paths?
I hope that made sense, thanks in advance for any guidance!
No. The URL goes to an entry-point in the app that is parsed by code. Each app can do it how it wants. It could just be a bunch of if/else statements.
Best bet is to ask the developer -- if they made these entry-points, they probably want people to know about them.
This might be a easy question but i couldn't find solution. I want to open AppWorld by clicking a button in my BB application. For example when user clicks this button Appworld will show "Facebook Application" page. Can i do this?
In Android platform this line launches GooglePlay for Facebook App. Does BlackBerry supports this kind of method?
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.facebook.katana")));
Here is a simple way to do this:
Browser.getDefaultSession().displayPage("http://appworld.blackberry.com/webstore/content/2360/?lang=en");
Above code will invoke the browser in the application and open the BlackBerry App World, I tested it in device and it's perfectly working. For now I put a Whats App messenger link, but you can customize the link according to your requirement.
You can open App World from your BB application directly using the following code. This code avoids opening the browser first.
Registry registry = Registry.getRegistry(this.getClass().getName());
Invocation invocation = new Invocation(null, null,
"net.rim.bb.appworld.Content",
false, ContentHandler.ACTION_OPEN);
invocation.setArgs(new String[] { /* app id in appworld */ });
registry.invoke(invocation);