Las*_*hds 11 cordova typescript ionic-framework cordova-plugins ionic3
Ionic社交共享插件无法在iOS上运行.错误响应返回"不可用".在Android上它按预期工作.我做错了吗?
// 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>
Run Code Online (Sandbox Code Playgroud)
首先,你没有分享你的整个功能,所以我要做一些假设.根据他们的文档,iOS有一些怪癖.
首先,让我们看看你的错误意味着什么.根据他们的文件:
如果未安装Facebook,将调用errorcallback并显示消息"not available"
结论:您要么未安装应用程序,要么您没有使用iOS前缀(请参阅下文)
编辑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>
Run Code Online (Sandbox Code Playgroud)
为了解决早先说的Quirk,也根据文档,谈论shareVia功能怪癖:
iOS:你只限于'com.apple.social.[facebook | twitter | 新浪微博| 腾讯微博]".如果应用程序不存在,则会调用errorcallback,iOS会显示一条弹出消息,要求用户配置应用程序.
这首先意味着,通过此shareVia功能,您只能分享到facebook,twitter,sinaweibo和tencentweibo(无论最后2个是什么)
其次,这意味着你需要在com.apple.social.之前添加app
基本上设置prefix = this.platform.is('ios') ? 'com.apple.social.' : '';然后使用
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, .....)
})
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1641 次 |
| 最近记录: |