Правильный способ использовать плагин Ioni c для обмена социальными сетями? - PullRequest
1 голос
/ 20 апреля 2020

Я пытаюсь внедрить плагин для обмена социальными сетями Ioni c в мое приложение, но у меня возникли проблемы.

Это ошибка, которую я получаю:

enter image description here

Вот мой 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?');
      //   });
    });
  }


}

Здесь это моя посылка. 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",
    "cordova-android": "^8.1.0",
    "cordova-plugin-browsertab": "0.2.0",
    "cordova-plugin-compat": "1.2.0",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-inappbrowser": "3.1.0",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^3.1.2",
    "cordova-plugin-splashscreen": "^5.0.3",
    "cordova-plugin-statusbar": "^2.4.3",
    "cordova-plugin-whitelist": "^1.3.4",
    "cordova-plugin-x-socialsharing": "^5.4.0",
    "cordova-universal-links-plugin": "^1.2.1",
    "cordova-universal-links-plugin-fix": "1.2.1",
    "core-js": "^2.6.10",
    "es6-promise-plugin": "^4.2.2",
    "firebase": "^5.11.1",
    "ionic": "^5.4.16",
    "jam-icons": "^2.0.0",
    "lodash": "^4.17.15",
    "messageformat": "^2.3.0",
    "moment": "^2.24.0",
    "ngx-toastr": "^9.1.2",
    "ngx-translate-messageformat-compiler": "^4.6.0",
    "ngx-ui-loader": "^7.2.2",
    "rxjs": "^6.5.4",
    "uuid": "^3.4.0",
    "web": "0.0.2",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/architect": "^0.803.25",
    "@angular-devkit/build-angular": "^0.803.25",
    "@angular-devkit/core": "^8.3.25",
    "@angular-devkit/schematics": "^8.3.25",
    "@angular/cli": "^8.3.25",
    "@angular/compiler": "^8.2.14",
    "@angular/compiler-cli": "^8.2.14",
    "@angular/language-service": "^8.2.14",
    "@biesbjerg/ngx-translate-extract": "^4.2.0",
    "@ionic/angular-toolkit": "^2.2.0",
    "@ionic/app-scripts": "^3.2.4",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "^2.0.8",
    "@types/moment": "^2.13.0",
    "@types/node": "^10.17.17",
    "codelyzer": "~4.5.0",
    "cypress": "^3.8.3",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.4",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^2.1.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.4.3",
    "ts-node": "^8.6.2",
    "tslint": "~5.12.0",
    "typescript": "3.5.3"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-ionic-keyboard": {},
      "cordova-universal-links-plugin": {},
      "cordova-plugin-browsertab": {},
      "cordova-plugin-inappbrowser": {},
      "cordova-plugin-x-socialsharing": {
        "ANDROID_SUPPORT_V4_VERSION": "24.1.1+"
      }
    },
    "platforms": [
      "android"
    ]
  }
}

Я пробовал разные часы в течение нескольких часов, но я просто не знаю, что мне не хватает. Есть ли специальный модуль для включения или что-то?

1 Ответ

0 голосов
/ 20 апреля 2020

Добавить Социальный обмен в app.module.ts в providers.

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

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [],
  providers: [
    ...
    SocialSharing,
    ...
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...