22

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

4
  • Hey @Hitu I am also looking for the same kind of functionality , have you got anything
    – user2028
    Dec 27, 2016 at 12:41
  • @Siddharth what kind of issue you are facing now ? Dec 28, 2016 at 9:57
  • @HituBansal did you ever end up figuring this out? The closest thing I've found was this engineering.curalate.com/2017/03/09/… but this is still hacky and doesn't sound like it will work that well. Then I found this which looks promising... github.com/j3k0/cordova-plugin-openwith Feb 10, 2018 at 7:49
  • Yes. i was able to fix that issue. Feb 14, 2018 at 4:58

6 Answers 6

17
+25

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>
8
  • I have implemented the same. i am not able to see my appicon, when i click share button from Safari Jun 4, 2015 at 6:22
  • What do you mean about appicon? For example you have a scheme like foo if app is installed on iOS device you can call it like href="foo://app/home" and it should open your app if not you are doing something wrong Jun 4, 2015 at 6:29
  • No, i guess you understand my question wrong. i am reading an article in safari browser. i want to share that link(url) to myapp. when i click share from safari, i want to list my app Jun 4, 2015 at 6:31
  • URLs belonging to a given URL type are characterized by their scheme components, such as http, ftp, mailto, or file. The CFBundleURLSchemes key in the scheme-definition dictionary specifies an array of schemes that characterize URLs of this type. So try to add http scheme to your app and i guess you can see your icon. Source:developer.apple.com/library/mac/documentation/Carbon/Conceptual/… Jun 4, 2015 at 7:19
  • can u provide an example for the same. i have no idea about that Jun 4, 2015 at 7:21
3

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

1
  • No, i am not asking about deep linking . i dnt want to open my app through browser Jun 8, 2015 at 2:55
3

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

7
  • Yes, but i am not able to implement this. Could you please provide any example for the same
    – soccer7
    Jun 15, 2015 at 4:38
  • @iMartin I thought there is a difference between an Action extension and a Sharing extension. Action implies viewing/transforming, while sharing is different?
    – Eno
    Jun 17, 2015 at 17:41
  • @Kamalpreet Because you are using some JavaScript wrapper?
    – Tricertops
    Jun 18, 2015 at 17:14
  • @Eno You are right there are two kinds: Share and Action extension. Share should send the content somewhere to the internet, while Action is used for all other non-sharing services. From what I understood, OP want to process the URL in app, so I suggested Action. They are otherwise very similar in implementation and usage.
    – Tricertops
    Jun 18, 2015 at 17:18
  • 1
    @Kamalpreet I never implemented one myself, but there is Xcode template to all kinds of extensions. It’s great place to start.
    – Tricertops
    Jun 18, 2015 at 17:20
1

Hope this vanger's post helps you.

In iOS to open any application you need to know which URLs schemes supported by this app.

For example, you can open email-writer by url like "mailto:aaa@bbb.com". But the thing is in application you can declare your own scheme. For example in App1 you can declare scheme like "my-app1-scheme". And in your second app you will need to open URL "my-app1-scheme://" and your App1 will be opened.

And I just found this plugin that allows you to do this in simpler way: https://github.com/EddyVerbruggen/Custom-URL-scheme

0

There seems to be a plugin now iOS-Phonegap-app-share-extension. I didn't try it though.

-1

On Android, you can use the WebIntent plugin to register your app as a receiver for the Share intent. Im not sure if a similar extension is available for iOS.

2
  • Yes, as I said above, Im not sure if something similar is available for iOS. I have also been using Ionic but Ive not (yet) found a Cordova plugin that hooks into the native sharing extensions and provides hooks into JavaScript. Am seriously considering writing my own.
    – Eno
    Jun 18, 2015 at 22:29
  • Is this what you are looking for? npmjs.com/package/cordova-plugin-openwith-ios
    – Phantom007
    Sep 24, 2018 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.