1

I thought it was as simple as using a URL scheme such as snapchat:// or instagram:// but I have tried this and nothing happens (in iOS or Android).

I'm trying to achieve this within a Cordova app. Ideally I'd like to launch Snapchat or Instagram and load a video in or open the 'browse gallery' page, but if that isn't possible I'd settle with just being able to open the apps themselves.

GoldenGonaz
  • 1,116
  • 2
  • 17
  • 42

2 Answers2

2

Two thoughts:

  1. If you already have the InAppBrowser plugin (cordova-plugin-inappbrowser) in your project, try calling window.open("snapchat://", "_system") (as per https://stackoverflow.com/a/17887465/2543147 this opens the browser app) which may then bounce the request onto the Snapchat app
  2. If that doesn't work, a plugin such as https://www.npmjs.com/package/cordova-plugin-app-launcher should allow you to do this easily.
Theo Gray
  • 89
  • 5
  • To use `windows.open` it's required [inappbrowser plugin](https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/) – Djiggy Jun 21 '17 at 11:58
0

This should work for iOS. UIApplication.shared().openURL(URL("snapchat://"))

For Android, its convenient to do the following.

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
if (launchIntent != null) { 
    startActivity(launchIntent);//null pointer check in case package name was not found
}

I also recommend referring to the following site for more information on instagram -> http://www.gotschemes.com/search/?app_id=5268

Your problem most likely stems for how this looks in cordova and how thats translates to the underlying native sdk, since otherwise you're right this is typically very straightforward and easy to do.

Evan Anger
  • 712
  • 1
  • 5
  • 24