ionic Cordova appAvailability 总是 return false
ionic Cordova appAvailability always return false
在我的 ionic 应用程序中,我需要检查设备上是否安装了 id facebook 和 twitter 应用程序。为此,我安装了 AppAvailability 并遵循以下指南:
let twitter = '';
let facebook = '';
if (this.plt.is('ios')) {
twitter = 'twitter://';
facebook = 'fb://';
} else if (this.plt.is('android')) {
twitter = 'com.twitter.android';
facebook = 'com.facebook.katana';
}
this.appAvailability.check(twitter)
.then(
(yes: boolean) => this.isTwitterAvailable = true,
(no: boolean) => this.isTwitterAvailable = false
);
this.appAvailability.check(facebook)
.then(
(yes: boolean) => this.isFacebookAvailable = true,
(no: boolean) => this.isFacebookAvailable = false
);
我总是得到 "false" 两者。应用程序已安装。我在 ionic dev 应用程序中尝试过,也尝试过在 realIOS 设备上使用真实应用程序。
我在某个地方的另一个答案中看到了它,但这是关于确保更新 plist 的事情。这是原始答案,所以如果它有效,我不能相信我知道答案,但希望它能有所帮助。
edit the plist (platforms/ios/appname/appname-Info.plist) file for
your app and add facebook.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>facebook</string>
</array>
有人也注意到它可能只是
<string>fb</string>
在 iOS11 中。但还没有检查过。
我根据 Indy-Jones 的回答做了什么:
<platform name="ios">
...
<edit-config file="*-Info.plist" mode="merge" target="LSApplicationQueriesSchemes">
<array>
<string>twitter</string>
<string>fb</string>
<string>instagram</string>
</array>
</edit-config>
....
</platform>
这将在 plist 文件中生成条目。
注:
- 在我的例子中,plist 没有更新。我删除并添加了 ios 平台;
- 这不适用于 ionic dev 应用程序,您必须在构建 ios 应用程序时对其进行测试。
在我的 ionic 应用程序中,我需要检查设备上是否安装了 id facebook 和 twitter 应用程序。为此,我安装了 AppAvailability 并遵循以下指南:
let twitter = '';
let facebook = '';
if (this.plt.is('ios')) {
twitter = 'twitter://';
facebook = 'fb://';
} else if (this.plt.is('android')) {
twitter = 'com.twitter.android';
facebook = 'com.facebook.katana';
}
this.appAvailability.check(twitter)
.then(
(yes: boolean) => this.isTwitterAvailable = true,
(no: boolean) => this.isTwitterAvailable = false
);
this.appAvailability.check(facebook)
.then(
(yes: boolean) => this.isFacebookAvailable = true,
(no: boolean) => this.isFacebookAvailable = false
);
我总是得到 "false" 两者。应用程序已安装。我在 ionic dev 应用程序中尝试过,也尝试过在 realIOS 设备上使用真实应用程序。
我在某个地方的另一个答案中看到了它,但这是关于确保更新 plist 的事情。这是原始答案,所以如果它有效,我不能相信我知道答案,但希望它能有所帮助。
edit the plist (platforms/ios/appname/appname-Info.plist) file for your app and add facebook.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>facebook</string>
</array>
有人也注意到它可能只是
<string>fb</string>
在 iOS11 中。但还没有检查过。
我根据 Indy-Jones 的回答做了什么:
<platform name="ios">
...
<edit-config file="*-Info.plist" mode="merge" target="LSApplicationQueriesSchemes">
<array>
<string>twitter</string>
<string>fb</string>
<string>instagram</string>
</array>
</edit-config>
....
</platform>
这将在 plist 文件中生成条目。 注:
- 在我的例子中,plist 没有更新。我删除并添加了 ios 平台;
- 这不适用于 ionic dev 应用程序,您必须在构建 ios 应用程序时对其进行测试。