Search code examples
ioscordovasmartbanner

Smart banner, app-argument and phonegap app


I am implementing Smart Banner for ios >=6.

When the user is on my website and click on the smart banner to open my phonegap application, I want to redirect him to the correct PATH of my application

According to the ios documentation, i need to use app-argument:

<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL">

How to intercept myURL in my phonegap application ? I can only find example in Obj-C


Solution

  • You have the full url in handleOpenUrl js function, native side of cordova in ios sends the url to this function. So, basically in your index.html file, try this before referencing cordova.js:

    <script type="text/javascript">
            function handleOpenURL(url) {               
                console.log("received url: " + url);
            }
    </script>
    

    You must also define the scheme (myapp in above example) in your ios app xcode settings.

    Note that you have to configure your web site properly to call your app with the correct scheme (i.e myapp://...). You can read more about deep linking here: https://developers.google.com/app-indexing/webmasters/

    Following plugin can help a lot, and supports both ios and android. https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin