[英]Ionic socialSharing plugin not working on iOS
Ionic social sharing plugin not working on iOS. Ionic社交共享插件无法在iOS上运行。 Error response returns 'not available'.
错误响应返回“不可用”。 On Android it works as expected.
在Android上它按预期工作。 Am I doing anything wrong?
我做错了吗?
// share functions parse accepts 'app' parameter
this.socialSharing.canShareVia(app, this.property.heading, '', '', this.property.link).then(res => {
this.socialSharing.shareVia(app, this.property.heading, '', '', this.property.link);
}).catch(res => {
this.gApp.hideLoading();
this.gApp.showAlert('error', res);
});
// app name is parsed from html
<a (click)="shareVia('facebook')">facebook</a>
...
<a (click)="shareVia('viber')">viber</a>
First of all you didn't share your entire function so I'm going to make some assumptions. 首先,你没有分享你的整个功能,所以我要做一些假设。 According to their docs iOS has some quirks.
根据他们的文档,iOS有一些怪癖。
So first things first let's see what your error means. 首先,让我们看看你的错误意味着什么。 According to their docs:
根据他们的文件:
If Facebook is not installed, the errorcallback will be invoked with message 'not available'
如果未安装Facebook,将调用errorcallback并显示消息“not available”
Conclusion: you either have the app not installed, or you're not using a prefix for iOS (read below) 结论:您要么未安装应用程序,要么您没有使用iOS前缀(请参阅下文)
Edit your config.xml
and add the following: 编辑
config.xml
并添加以下内容:
<platform name="ios">
<!-- add this entry -->
<config-file platform="ios" target="*-Info.plist" parent="LSApplicationQueriesSchemes">
<array>
<string>facebook</string>
<!-- ...... -->
<string>viber</string>
</array>
</config-file>
</platform>
To solve earlier said Quirk, also according to the docs , talking about shareVia
function quirks: 要解决早先说的Quirk,还要根据文档 ,谈论
shareVia
函数的怪癖:
iOS: You are limited to 'com.apple.social.[facebook |
iOS:你只限于'com.apple.social。[facebook | twitter |
twitter | sinaweibo |
新浪微博| tencentweibo]'.
腾讯微博]”。 If an app does not exist, the errorcallback is invoked and iOS shows a popup message asking the user to configure the app.
如果某个应用程序不存在,则会调用errorcallback,iOS会显示一条弹出消息,要求用户配置该应用程序。
This first of all means that, with this shareVia
function, you can only share to facebook, twitter, sinaweibo and tencentweibo (whatever those last 2 are) 这首先意味着,有了这个
shareVia
功能,你只能分享到facebook,twitter,sinaweibo和tencentweibo(无论最后2个是什么)
Second of all it means that you need to add com.apple.social.
其次,这意味着您需要添加
com.apple.social.
before the app
在
app
之前
Basically setting prefix = this.platform.is('ios') ? 'com.apple.social.' : '';
基本上设置
prefix = this.platform.is('ios') ? 'com.apple.social.' : '';
prefix = this.platform.is('ios') ? 'com.apple.social.' : '';
and then using 然后使用
import { Platform } from '@ionic-angular';
...
shareVia(app) {
// only prefix on ios
let prefix = this.platform.is('ios') ? 'com.apple.social.' : '';
// NOTE: canShareVia doesn't need the prefix!
this.canShareVia(app, .....).then(() => {
// shareVia *does* require the prefix on ios.
// This returns 'not available' if the first parameter provided doesn't match an *installed* app.
this.shareVia(prefix + app, .....)
})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.