使用 Ionic 在 Android/iOS 上执行外部应用程序
executing external apps on Android/iOS with Ionic
在我的 Ionic 应用程序中,我尝试在每次单击按钮时执行各种应用程序。以下函数在 Android 和 iOS 上启动 Skype。来自 Skype 的 URI for Androis 是 com.skype.raider
而对于 iOS 是 skype://
function launchSkype() {
var scheme;
if (device.platform === 'iOS') {
scheme = 'skype://';
} else if (device.platform === 'Android') {
scheme = 'com.skype.raider';
} else if (device.platform === 'wp') {
scheme = 'skype:';
} else if (device.platform === 'windows8') {
scheme = 'skype:';
}
navigator.startApp.check(scheme, function(message) { /* success */
navigator.startApp.start(scheme, function(message) {
}, function(error) { /* error */
alert("Skype could not be started!");
});
}, function(error) {
alert("Skype is not installed!");
});
}
找到各个应用程序的 Intent links (URI) 很重要,运行 这些在 Android/iOS 上。 我很难找到 iOS 的 URI link。在Android上,很容易找到。上Google播放各自的App ID是在地址栏中找到。
我的问题是,在哪里可以找到 iOS 应用程序的应用程序 ID 以启动 ?我将为其他应用程序开发相同的功能。我只需要 ID。
我需要例如这些(本机)应用程序的 ID 来执行:
- 本机的 URI "Email app" (Android / iOS)
- 本机的 URI "Address Book" (Android / iOS)
- 本机的 URI "My Documents" (Android / iOS)
编辑:
所以,我为 android 找到了一个名为 Package Name Viewer 的应用程序,它给出了所有已安装应用程序的包名称。 iOS 有类似的东西吗?通过该应用程序,我找到了以下包名称:
com.android.email
com.android.contacts
com.sec.android.app.myfiles
第二点,所以com.android.contacts
不会直接显示给Android上的联系人。哪个 link 显示设备上直接存储的联系人是正确的?
iOS 不允许这种行为。已经有人试图规避这一点,根据 this Whosebug answer[1] 你可以尝试看看 URI 是否可以打开
引用自其他回答:
- if the app is known to handle URLs of a certain type
- by using [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"thisapp://foo"]
You can get a list of apps and URL schemes from here.
在我的 Ionic 应用程序中,我尝试在每次单击按钮时执行各种应用程序。以下函数在 Android 和 iOS 上启动 Skype。来自 Skype 的 URI for Androis 是 com.skype.raider
而对于 iOS 是 skype://
function launchSkype() {
var scheme;
if (device.platform === 'iOS') {
scheme = 'skype://';
} else if (device.platform === 'Android') {
scheme = 'com.skype.raider';
} else if (device.platform === 'wp') {
scheme = 'skype:';
} else if (device.platform === 'windows8') {
scheme = 'skype:';
}
navigator.startApp.check(scheme, function(message) { /* success */
navigator.startApp.start(scheme, function(message) {
}, function(error) { /* error */
alert("Skype could not be started!");
});
}, function(error) {
alert("Skype is not installed!");
});
}
找到各个应用程序的 Intent links (URI) 很重要,运行 这些在 Android/iOS 上。 我很难找到 iOS 的 URI link。在Android上,很容易找到。上Google播放各自的App ID是在地址栏中找到。
我的问题是,在哪里可以找到 iOS 应用程序的应用程序 ID 以启动 ?我将为其他应用程序开发相同的功能。我只需要 ID。
我需要例如这些(本机)应用程序的 ID 来执行:
- 本机的 URI "Email app" (Android / iOS)
- 本机的 URI "Address Book" (Android / iOS)
- 本机的 URI "My Documents" (Android / iOS)
编辑:
所以,我为 android 找到了一个名为 Package Name Viewer 的应用程序,它给出了所有已安装应用程序的包名称。 iOS 有类似的东西吗?通过该应用程序,我找到了以下包名称:
com.android.email
com.android.contacts
com.sec.android.app.myfiles
第二点,所以com.android.contacts
不会直接显示给Android上的联系人。哪个 link 显示设备上直接存储的联系人是正确的?
iOS 不允许这种行为。已经有人试图规避这一点,根据 this Whosebug answer[1] 你可以尝试看看 URI 是否可以打开
引用自其他回答:
- if the app is known to handle URLs of a certain type
- by using [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"thisapp://foo"]
You can get a list of apps and URL schemes from here.