【发布时间】:2020-01-05 10:32:35
【问题描述】:
我正在使用 Ionic 3 应用程序,试图让社交分享发挥作用。
我按照以下步骤安装了 Ionic Native Social Sharing 插件:https://ionicframework.com/docs/v3/native/social-sharing/
跑:
$ ionic cordova plugin add cordova-plugin-x-socialsharing
$ npm install --save @ionic-native/social-sharing@4
通过我的应用模块导入插件(版本 4.x.x)并将 SocialSharing 添加到提供程序数组中。
通过我的 app.component 导入插件:
import { SocialSharing } from '@ionic-native/social-sharing';
添加到构造函数中:
private socialSharing: SocialSharing
这个分享功能,也在 app.component 中通过 html(侧边菜单)中的按钮触发:
async share() {
try {
// Pop the native social sharing sheet, allowing the user to choose how to share the app.
await this.socialSharing.share(this.shareMessage, this.shareSubject, this.shareFile, this.getShareUrl());
this.toast.show('Thanks for sharing!', 3000);
}
catch(err) {
console.error(err);
alert(err);
}
}
我正在使用平台:ios、android 和浏览器。
当我从真实设备上的构建中调用该方法时,我得到了错误:
“未安装插件”
试过了:
检查日志以查找安装错误。没见过。
重新安装插件。
使用 $ionic cordova 插件列表检查的插件存在。 cordova-plugin-x-socialsharing 5.4.7 “SocialSharing”存在。
删除并再次添加所有平台。
将 share 方法包装在 platform.ready() 中。
似乎没有任何效果。我无法让应用识别插件已安装!
请帮忙! :slight_smile: 接下来我可以尝试什么?
谢谢
$离子信息:
离子:
Ionic CLI:5.2.3 (/usr/local/lib/node_modules/ionic) 离子框架:离子角 3.9.5 @ionic/app-scripts:3.2.2
科尔多瓦:
Cordova CLI:9.0.0 (cordova-lib@9.0.1) Cordova 平台:android 8.0.0,浏览器 6.0.0,ios 5.0.1 Cordova 插件:cordova-plugin-ionic 5.4.0、cordova-plugin-ionic-keyboard 2.1.3、cordova-plugin-ionic-webview 2.5.1(和其他 13 个插件)
实用程序:
cordova-res:0.4.0(可用更新:0.6.0) 本机运行:未安装
系统:
ios 部署:1.9.4 ios-sim : 8.0.2 NodeJS:v11.2.0 (/usr/local/Cellar/node/11.2.0/bin/node) npm:6.9.2 操作系统:macOS Mojave Xcode:Xcode 10.2 构建版本 10E125
【问题讨论】:
-
你能提供 Ionic 信息或运行另一个命令来准确显示你正在使用的 ionic 版本吗?
-
嗨,谢尔盖,我已经用我的离子信息编辑了上面的内容。感谢您的观看!