简体   繁体   English

Ionic socialSharing插件无法在iOS上运行

[英]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.

相关问题 Phonegap / Cordova:社交共享插件不起作用 - Phonegap / Cordova: socialsharing plugin not working 离子无法添加SocialSharing-PhoneGap-插件 - ionic unable to add SocialSharing-PhoneGap-Plugin 仅适用于IOS的Whatsapp上的cordova / ionic社会共享错误 - cordova/ionic socialsharing error on Whatsapp only for IOS 在ionic 3中使用socialSharing插件时我的应用程序崩溃 - my app crash when use socialSharing plugin in ionic 3 Ionic Cordova Social Share 插件 - 无法读取未定义的属性“socialsharing” - Ionic Cordova Social Share plugin - cannot read property 'socialsharing' of undefined Phonegap:SocialSharing phonegap插件不适用于FBDialog中的预填充消息 - Phonegap: SocialSharing phonegap plugin not working with pre filled message in FBDialog 更新 cordova-plugin-x-socialsharing 插件后,Ionic Android 构建错误 - Ionic Android build error after updating cordova-plugin-x-socialsharing plugin 离子科尔多瓦网络信息插件无法在iOS中使用 - Ionic cordova network information plugin not working in ios 没有适用于ionic3 ios项目的与ionic-native兼容的cordova插件 - No cordova plugin working with ionic-native for ionic3 ios project 如何通过ionic中的socialsharing插件共享一组图像文件链接或多个图像? - How to share an array of image file links or multiple images through socialsharing plugin in ionic?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM