Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Receive URL in Ionic for ios

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

like image 513
Hitu Bansal Avatar asked May 25 '15 06:05

Hitu Bansal


3 Answers

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>
like image 107
engincancan Avatar answered Oct 21 '22 23:10

engincancan


what you are asking is deep linking facility for your app. Although I can't provide you exact solution but its fairly simple by writing few lines of code into your native ios app's .plist file (just like what you did for android in manifest.xml). Its called URL scheming, and you can make one for your ios app too.

Please go to http://docs.urbanairship.com/topic-guides/ios-deep-linking.html. I hope it provides you guidance over how you can do this.

The angular/ionic code which opens 'another app that has provided deep linking facility(like youtube,etc.)' - https://medium.com/angularjs-articles/deep-linking-in-ionic-mobile-applications-44d8b4685bb3

like image 38
Vineet 'DEVIN' Dev Avatar answered Oct 22 '22 00:10

Vineet 'DEVIN' Dev


What you are looking for is called Action Extension introduced in iOS 8. Your app will appear in standard acton/share sheet in all system and 3rd party apps and will be able to handle any kind of data, not just URLs.

App Extension Programming Guide from Apple

like image 23
Tricertops Avatar answered Oct 21 '22 22:10

Tricertops