为了账号安全,请及时绑定邮箱和手机立即绑定

使用 Ionic 的社交分享插件的正确方法?

使用 Ionic 的社交分享插件的正确方法?

aluckdog 2022-07-08 18:19:29
我正在尝试在我的应用程序中实现 Ionic 的社交分享插件,但我遇到了问题。这是我得到的错误:这是我的 component.tsimport {SocialSharing} from '@ionic-native/social-sharing/ngx';export class SettingsPage implements OnInit {  code: string = null;  constructor(    private socialSharing: SocialSharing  ) {}  ngOnInit() {}  shareCode(code) {    this.socialSharing.canShareViaEmail().then(() => {      // this.socialSharing      //   .share(`Here is your code: ${code}`)      //   .then(() => {      //     log.debug('code has been shared?');      //   });    });  }}这是我的 package.json{  "dependencies": {    "@angular/common": "^8.2.14",    "@angular/core": "^8.2.14",    "@angular/forms": "^8.2.14",    "@angular/http": "^7.2.16",    "@angular/platform-browser": "^8.2.14",    "@angular/platform-browser-dynamic": "^8.2.14",    "@angular/pwa": "^0.803.25",    "@angular/router": "^8.2.14",    "@angular/service-worker": "^8.2.14",    "@biesbjerg/ngx-translate-extract-marker": "^1.0.0",    "@fullcalendar/core": "^4.4.0",    "@fullcalendar/daygrid": "^4.4.0",    "@fullcalendar/interaction": "^4.4.0",    "@fullcalendar/resource-common": "^4.4.0",    "@fullcalendar/timegrid": "^4.4.0",    "@ionic-native/core": "^5.22.0",    "@ionic-native/in-app-browser": "^5.22.0",    "@ionic-native/social-sharing": "^5.22.0",    "@ionic-native/splash-screen": "^5.22.0",    "@ionic-native/status-bar": "^5.22.0",    "@ionic/angular": "^4.11.10",    "@ionic/pro": "2.0.4",    "@ionic/storage": "^2.2.0",    "@ngx-translate/core": "^12.1.2",    "@sentry/browser": "^4.6.6",    "angular2-counto": "^1.2.5",    "angularfire2": "^5.4.2",    "cordova": "^9.0.0",  }我已经尝试了几个小时的不同,但我只是不知道我错过了什么。是否有要包含的特殊模块或其他内容?
查看完整描述

2 回答

?
心有法竹

TA贡献1866条经验 获得超5个赞

将社交分享添加到app.module.ts下providers。


import { SocialSharing } from '@ionic-native/social-sharing/ngx';


@NgModule({

  declarations: [AppComponent],

  entryComponents: [],

  imports: [],

  providers: [

    ...

    SocialSharing,

    ...

  ],

  bootstrap: [AppComponent]

})

export class AppModule {}


查看完整回答
反对 回复 2022-07-08
?
哔哔one

TA贡献1854条经验 获得超8个赞

很重要!我解决了 Android 中的一个问题的更新,即:@dipesious

您将获得一系列不同的包作为 .catch(error) 这意味着您没有向清单添加 QUERY_ALL_PACKAGES 权限。将此添加到您的 Android 清单文件中:祝贺 BUG RESOLVED...


查看完整回答
反对 回复 2022-07-08
  • 2 回答
  • 0 关注
  • 133 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号