繁体   English   中英

@ ionic-native / push的离子问题

[英]ionic issues with @ionic-native/push

几天以来,我一直在尝试使推送通知在ionic中起作用,到目前为止,我已经完成了7个教程,但是一旦我到达了开始测试的地步,每个教程都会失败! 仅仅是我还是所有这些教程都过时了?

到目前为止,我已经尝试了以下教程:

  • c-sharpcorner.com
  • saowen.com
  • medium.com
  • sitepoint.com
  • masteringionic.com
  • thielcole.github.io
  • luisjordan.net

对于这些教程中的每一个,我都会碰到关于“推”模块的问题,一种或另一种方式是我不断遇到这些相同的错误,不同的教程之间有一些很小的变化,但是总的来说,这些都是相同的错误,下面的错误会出现从我遵循的最新教程(luisjordan教程)中可以得出:

From the app.component.ts file, i get an error for the constructor:
----------------------
typescript: C:/Users/***/Documents/ionic/push-luisjordan/src/app/app.component.ts, line: 15
Cannot find name 'Push'.

L15:  constructor (platform : Platform, statusBar : StatusBar, splashScreen : SplashScreen, private push : Push) {
L16:              platform.ready().then(() => {
----------------------

And from app.module.ts file, i get an error for the providers:
----------------------
typescript: C:/Users/***/Documents/ionic/push-luisjordan/src/app/app.module.ts, line: 12
Argument of type '{ declarations: (typeof HomePage | typeof MyApp)[]; imports: (ModuleWithProviders | typeof
Browse...' is not assignable to parameter of type 'NgModule'. Types of property 'providers' are
incompatible. Type '(typeof SplashScreen | PushOriginal | { provide: typeof ErrorHandler; useClass: typeof
IonicError...' is not assignable to type 'Provider[]'. Type 'typeof SplashScreen | PushOriginal | { provide:
typeof ErrorHandler; useClass: typeof IonicErrorH...' is not assignable to type 'Provider'. Type
'PushOriginal' is not assignable to type 'Provider'. Type 'PushOriginal' is not assignable to type
'ClassProvider'. Property 'provide' is missing in type 'PushOriginal'.

L12:  @NgModule({                                                                                                                                                                                                                                                                                                        
L13:    declarations: [

为了防止将它变成更大的文本墙,我制作了以下pastebin页面,它包含上面发布的相同错误,但更重要的是,它还包含app.component.ts&app.module.ts

https://pastebin.com/RUH9egA9

为了帮助加快处理速度,以下是版本号概述以及对常见问题的一些答复,我在其他离子问题上也看到了这些答复:

$ ionic info

Ionic:

   ionic (Ionic CLI)  : 4.8.0 (C:\Users\Olivier\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.1

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.2, (and 7 other plugins)

System:

   NodeJS : v10.2.1 (C:\Program Files\nodejs\node.exe)
   npm    : 6.5.0
   OS     : Windows 10



$ ionic cordova plugins
> cordova plugin ls

You have been opted out of telemetry. To change this, run: cordova telemetry on.
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 2.3.2 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-support-google-services 1.1.0 "cordova-support-google-services"
phonegap-plugin-multidex 1.0.0 "Multidex"
phonegap-plugin-push 2.2.3 "PushPlugin"



$ ionic cordova platform list
> cordova platform ls

You have been opted out of telemetry. To change this, run: cordova telemetry on.
Installed platforms:
  android 7.1.4
Available platforms:
  browser ~5.0.1
  ios ~4.5.4
  osx ~4.0.1
  windows ~6.0.0
  • 在工作目录中,我已经使用“ npm install --save @ ionic-native / push”安装了模块
  • 我确保添加了android平台,并使用“离子Cordova模拟android”进行了测试
  • 我已经编辑config.xml,使其具有与我的Firebase应用程序匹配的小部件ID(我想这是超前的吗?)

有人知道什么地方可能出问题吗? 我已经读了好几天了,但我仍然不知道我可能会缺少什么? 每次遇到离子不会接受推送模块的同一问题... :(

在此先感谢您,如果有人在此留言后还有其他疑问,请随时提出。

似乎Ionic团队最近对其原生插件进行了更改。

您似乎已安装了ionic 4支持的插件(版本> = 5.0.0)。由于使用的是ionic 3,请卸载该插件并安装4.20.0版本。

npm uninstall @ionic-native/push

接着

npm i -s @ionic-native/push@4.20.0

有关更多详细说明,您可以查看此答案https://stackoverflow.com/a/54398403/6617276

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM