简体   繁体   English

向ngCordova注册Android推送通知时出现processMessageFailed错误

[英]processMessageFailed error when registering Android push notifications with ngCordova

Because of some other application requirements I need to bootstrap angular. 由于其他一些应用程序要求,我需要引导角度。 This has caused problems when registering android notifications using ngCordova push notification ($cordovaPush). 使用ngCordova 推送通知 ($ cordovaPush)注册android通知时,这会导致问题。

I'm seeing a "processMessage failed: Error:" 我看到“ processMessage失败:错误:”

processMessage failed: Error: Error: [$injector:unpr] Unknown provider: $cordovaPushProvider <- $cordovaPush
http://errors.angularjs.org/1.3.6/$injector/unpr?p0=%24cordovaPushProvider%20%3C-%20%24cordovaPush 
cordova.js:1059
processMessage failed: Stack: Error: [$injector:unpr] Unknown provider: $cordovaPushProvider <- $cordovaPush
http://errors.angularjs.org/1.3.6/$injector/unpr?p0=%24cordovaPushProvider%20%3C-%20%24cordovaPush
    at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:7888:12
    at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:11806:19
    at Object.getService [as get] (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:11953:39)
    at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:11811:45
    at Object.getService [as get] (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:11953:39)
    at eval (eval at processMessage (file:///android_asset/www/cordova.js:1021:26), <anonymous>:1:75)
    at processMessage (file:///android_asset/www/cordova.js:1021:13)
    at Function.androidExec.processMessages (file:///android_asset/www/cordova.js:1091:13)
    at pollOnce (file:///android_asset/www/cordova.js:956:17)
    at pollOnceFromOnlineEvent (file:///android_asset/www/cordova.js:946:5) 
cordova.js:1060
processMessage failed: Message: Jjavascript:angular.element(document.querySelector('[ng-app]')).injector().get('$cordovaPush').onNotification({"regid":"APA91bEX-nZgrUPmxMxWKiIZpAi8zAaSgr58es6YXvaVk_wEffvm0pKPs-WNIxF-fTiYMxzxkZAxAul96ZxYVixWgSRs2VRn6NcTmPQXeQ7oXFghoL_Ya0cIbPLI1IQqOjPJzdVL974yV1A6VxFLwNHH1cjLkRp0-IIz6WaU4pHgImdOUD7HkOc","event":"registered"}) B

I followed the trace and identified the line below as the culprit. 我跟踪了踪迹,并将下面的行确定为罪魁祸首。

config.ecb = "angular.element(document.querySelector('[ng-app]')).injector().get('$cordovaPush').onNotification";

The error is caused by angular.element(document.querySelector('[ng-app]')) returning undefined. 该错误是由angular.element(document.querySelector('[ng-app]'))返回未定义引起的。

A more correct way to access $injector in my case is to use this query (credit to Ionic blog post ): 在我的情况下,访问$ injector的一种更正确的方法是使用此查询(贷记给Ionic博客文章 ):

angular.element(document.querySelector('html'))

There are two ways to solve this problem. 有两种方法可以解决此问题。

  1. Change ng-cordova.js directly by editing the query. 通过编辑查询直接更改ng-cordova.js。
  2. Add an 'ecb' field to your config object. 将“ ecb”字段添加到您的配置对象。 The value of the 'ecb' field should be angular.element(document.querySelector('html')).injector().get('$cordovaPush').onNotification 'ecb'字段的值应为angular.element(document.querySelector('html')).injector().get('$cordovaPush').onNotification

There is more information on this in an issue forum . 问题论坛中有关于此的更多信息。 I found that none of the solutions presented worked for me until I found the above suggested query. 我发现在找到上述建议的查询之前,没有提出的解决方案对我有用。

I'd love to see any additional solutions if there are any! 我希望看到任何其他解决方案,如果有的话!

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

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