猿问

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

我正在尝试在我的应用程序中实现 Ionic 的社交分享插件,但我遇到了问题。

这是我得到的错误:

这是我的 component.ts


import {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",

  }


我已经尝试了几个小时的不同,但我只是不知道我错过了什么。是否有要包含的特殊模块或其他内容?


aluckdog
浏览 135回答 2
2回答

心有法竹

将社交分享添加到app.module.ts下providers。import { SocialSharing } from '@ionic-native/social-sharing/ngx';@NgModule({  declarations: [AppComponent],  entryComponents: [],  imports: [],  providers: [    ...    SocialSharing,    ...  ],  bootstrap: [AppComponent]})export class AppModule {}

哔哔one

很重要!我解决了 Android 中的一个问题的更新,即:@dipesious您将获得一系列不同的包作为 .catch(error) 这意味着您没有向清单添加 QUERY_ALL_PACKAGES 权限。将此添加到您的 Android 清单文件中:祝贺 BUG RESOLVED...
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答