Receive URL in Ionic for ios

cordova, ionic-framework, ios, phonegap-plugins

Solution

All you need is Custom-URL-scheme cordova plugin.

You can do it manually also. For iOS add to your *.plist. Or You can look at Step 5

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>URL_SCHEME</string>
    </array>
  </dict>
</array>

In iOS after adding custom scheme it automatically calls a function called `handleOpenURL`.

For android add AndroidManifest:(In android you can even listen http scheme)

<activity android:label="@string/app_name" android:name="com.yourpackage.name">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="http" android:host="example.com" android:pathPrefix="/" />
        <data android:scheme="https" android:host="example.com" android:pathPrefix="/" />
    </intent-filter>
</activity>

Problem

I am using ionic framework. I'm trying to set up a way to receive a url from another app. Like, you are in browser, click share, and send the link to another app (my app). I found this cordova plugin, and have integrated it in my app. But this is pulgin for Android. I need same functionality in IOS. Any idea which plugin i need to use for ios Steps taken by me for Android 1) cordova plugin add git://github.com/Initsogar/cordova-webintent.git 2) Checked config.xml file and found code for webintent ``` <intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent-filter> ``` And app.js code ``` if (window.plugins && window.plugins.webintent) { window.plugins.webintent.getUri(function(url) { alert("getUri url:"+url); }); } ``` Any suggestions for the same functionally in ios ? Thank you

Original source

Related problems