Receive URL in Ionic for ios

后端 未结 6 1862
逝去的感伤
逝去的感伤 2021-02-02 11:11

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 fo

相关标签:
6条回答
  • 2021-02-02 11:40

    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.

    0 讨论(0)
  • 2021-02-02 11:42

    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>
    
    0 讨论(0)
  • 2021-02-02 11:47

    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 讨论(0)
  • 2021-02-02 11:53

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

    0 讨论(0)
  • 2021-02-02 11:55

    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

    0 讨论(0)
  • 2021-02-02 12:00

    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

    0 讨论(0)
提交回复
热议问题