Open the application from SMS with my URL scheme as a link

I declared the URL scheme in my smstest application, so in Safari I can write smstest:my-test or smstest://my-test in the search bar and my application is open.

I am trying to achieve the same from SMS text so that the Messages application formats smstest:my-test or smstest://my-test as a link, and the user can click on it and call my application. But the text is not formatted as a link.

Is this possible or the only solution to open the application from SMS is to point to the Internet page with a script?

Thanks.

EDIT: funny, I installed IMO Messenger, and I get an SMS with the code in the form of a URL scheme, and it is parsed by the Messages application as a link. Why does not happen with my application? I tried with multiple posts, with spaces before and after the url, and nothing happens.

+7
ios url-scheme
source share
2 answers

In general, there is a standard way to open an application from the Messages application using the URL scheme:

  • Add the URL scheme to the info.plist: my-scheme file.
  • Install the application on the target iPhone.
  • Send an SMS with the text as follows: "my-scheme: // it-is-my-scheme.

And everything works well. But maybe one interesting case is when it does not work, and you think that the source code is incorrect. But this is not so. Let's try to investigate this case:

  • Before adding a URL scheme and installing the application, send an SMS. Since the expected message will be displayed as plain text:
    First SMS

  • Now add the url to info.plist:
    Info.plist

  • Finally, install the application and send / receive the same SMS:
    Second SMS

As you can see, the last message is displayed as a link, and if I touch it, then iOS will open my application. But the first message is still displayed as plain text, and it is not amenable to discussion. It seems that the logic of the Messages application is implemented in this way.

Now you can remove the application from the iPhone and send the same SMS again:
Third SMS
Now it is displayed again as plain text, and the second message as a link. And if I touch it, iOS does nothing and leaves the Messages message open.

Conclusion: Be sure to send / receive SMS after installing an application that supports your scheme. Only in this case it will be displayed as a link, and the user can open your application by clicking on it.

Note: I will also catch one case where at the beginning of the application it was installed without supported url schemes, and then when I add this support message, it appears as plain text, but not as a link. I can not reproduce it. But if the above steps do not solve the problem, follow these steps:

  • Uninstall the application from the iPhone;
  • Change the URL scheme (or even change both the URL scheme and the package identifier as a last resort);
  • Install it again;
  • Send SMS with the new URL scheme.
+14
source share

EDIT:

I just tried an application that sent my url scheme to sms body and worked. It should have this format smstest://my-test

The application should be installed with the url-scheme declared in info.plist when you get sms to work.

I am adding a screenshot of the SMS received with various URL schemes, all of which are recognized by the iPhone application for iPhone.

SMS URL SCHEMES

If this still does not work, try to execute and return them to YES

application: handleOpenURL: and application: openURL:sourceApplication: annotation:

 - (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url { return YES; } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return YES; } 

This old answer was for the JS redirect you asked for in the comments.

I use this to redirect from the Internet to the application, returning to the itunes URL in case the application is not installed

 var now = new Date().valueOf(); setTimeout(function () { if (new Date().valueOf() - now > 100) return; window.location = "http://itunes.apple.com/yourappurl"; }, 25); window.location = "smstest://my-test"; 
+3
source share

All Articles