Best practice to hide URL scheme from end users

I want to send text messages to an application that are links to open other views inside the same application. As a text notification message that has links to other views in the application. Thus, the best way to do this is to insert the URL scheme myAppName://someQuery?blablabla=123 , and this should in turn run the openURL command and open this particular view.

What is the best practice to hide the URL scheme from the end user. It looks ugly and also does not want to create an opportunity when the end user can pass values ​​to the URL scheme.

My parameters:

  • Use the web link, open the safari, and then return to the app. It takes time.
  • Use the html tags <a href=myAppName://someQuery?blablabla=123">Test</a> , but this affects performance, since I need to continue to assign attribute text to the text element, and it is very slow and buggy.

So far, the best option I have is 2. Just wondering if there are other good ideas out there ...

thanks for the help

+7
ios objective-c cocoa-touch url-scheme
source share
2 answers

You can encrypt the parameter string and then send it as a message

Encrypted URL Form:

 myAppName://encrypted_query 

Now, when you receive a call in your application, you must output encryptedt_data from the URL and decrypt it before doing anything.

Decrypted URL Form:

 myAppName://someQuery?blablabla=123 

In my opinion, this is the best and easiest way to do this. For best encryption / decryption practices, check out AES Encryption for NSString on iPhone and this .

As long as you are not worried about security, you can always use a reduced encryption string size to reduce the URL. This option is provided in the Github library.

+4
source share

So, the best way to do this is to insert the URL scheme myAppName://someQuery?blablabla=123 , and this should in turn run the openURL command and open this particular view.

I assume that you are using a web view and why you want to do so. But do you know about the WKScriptMessageHandler protocol in the new WKWebView class?

If you insert onclick='window.webkit.messageHandlers.yourHandlerName.postMessage(yourUserData)' on a web page and configure one or more script message handlers via the WKUserContentController your WKWebView , their methods -userContentController:didReceiveScriptMessage: will be called using body messages.

+1
source share

All Articles