Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SenderID is not set up correctly when initializing app #64

Closed
VVelda opened this issue Nov 18, 2020 · 3 comments
Closed

SenderID is not set up correctly when initializing app #64

VVelda opened this issue Nov 18, 2020 · 3 comments

Comments

@VVelda
Copy link

VVelda commented Nov 18, 2020

Bug Report

When initializing Push Plugin through the JS call, following exception is thrown:
E/Push_Plugin: execute: Got Resources NotFoundException String resource ID #0x0

Seems related to this unfixed bug in the original repo:
phonegap#1800

The google-services.json is on its place and I tried to clean the app and build again too.

From that issue seems it's conflict with InAppBrowser pluging, or rather the order these two plugins are installed, but I tried to reinstall cordova-plugin-push and uninstall InAppBrowser one, but the result is still same.

I found a difference between the two plugins in android/app/build.gradle file, which misses these lines after the update:

@@ -101,2 +100,0 @@ ext {
-apply from: "../cordova-support-google-services/restaurater-build.gradle"
-apply from: "../phonegap-plugin-multidex/restaurater-multidex.gradle"

I found out a commit what is most likely breaking up the plugin:
#8
Therefore, for now I'm staying with the original plugin, which works just well.

Expected Behaviour

The app should be set for receiving FCM notifications. As part of this, SenderID should be saved into SharedPreferences.

Actual Behaviour

Init call will fire error event. The cause is value for gcm_defaultSenderId is not found. Therefore SendeID is not set and any incoming notification is not shown. I've moved from phonegap-push-plugin where I didn't have this problem.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

  1. Install this plugin
  2. Run the application on the device
  3. Call PushNotification.init function

Platform and Version

Android 9

(Android) Device Vendor

Sony Xperia XA2

cordova info Printout

cordova-lib@9.0.1 with:
cordova-common@3.2.1
cordova-create@2.0.0
cordova-fetch@2.0.1
cordova-serve@3.0.0

Environment:
OS: win32
Node: v12.16.2
npm: 6.14.4

Plugins:
com.cordova.plugins.cookiemaster
cordova-install-referrer-api
cordova-plugin-dialogs
cordova-plugin-inappbrowser
cordova-plugin-whitelist
cordova-support-google-services
havesource-cordova-plugin-push
phonegap-plugin-multidex

EOF

package.json <<EOF

{
  "name": "cz.menicka.restaurater",
  "displayName": "Restauratér",
  "version": "1.0.0",
  "description": "A sample Apache Cordova application that responds to the deviceready event.",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "ecosystem:cordova"
  ],
  "author": "Apache Cordova Team",
  "license": "Apache-2.0",
  "dependencies": {
    "@havesource/cordova-plugin-push": "^1.0.0",
    "cordova-android": "^8.1.0",
    "cordova-install-referrer-api": "0.0.1",
    "cordova-plugin-cookiemaster": "^1.0.5",
    "cordova-plugin-dialogs": "^2.0.2",
    "cordova-plugin-inappbrowser": "^4.0.0",
    "cordova-support-google-services": "^1.3.2",
    "phonegap-plugin-multidex": "^1.0.0"
  },
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-install-referrer-api": {},
      "cordova-plugin-inappbrowser": {},
      "com.cordova.plugins.cookiemaster": {},
      "cordova-plugin-dialogs": {},
      "havesource-cordova-plugin-push": {
        "ANDROID_SUPPORT_V13_VERSION": "28.0.0",
        "FCM_VERSION": "18.+"
      }
    },
    "platforms": [
      "android"
    ]
  },
  "devDependencies": {
    "cordova-plugin-whitelist": "^1.3.4"
  }
}

EOF

Sample Push Data Payload

Sample Code that illustrates the problem

            var push = PushNotification.init({
                android: {
                    // Work just for data messages (handled by plugin; not for those handled by FCM itself):
                    icon: "ic_notification",
                    iconColor: "#EA654B",
                    forceShow: true,
                    vibrate: true
                },
                ios: {
                    alert: "true",
                    badge: "true",
                    sound: "true"
                }
            })

Logs taken while reproducing problem

2020-11-18 20:58:38.930 23504-23622/cz.Menicka.restaurater V/Push_Plugin: execute: action=createChannel
2020-11-18 20:58:38.957 23504-23622/cz.Menicka.restaurater V/Push_Plugin: execute: action=init
2020-11-18 20:58:38.960 23504-23623/cz.Menicka.restaurater V/Push_Plugin: execute: data=[{"android":{"icon":"ic_notification","iconColor":"#EA654B","forceShow":true,"vibrate":true},"ios":{"alert":"true","badge":"true","sound":"true"}}]
2020-11-18 20:58:38.992 23504-23623/cz.Menicka.restaurater V/Push_Plugin: execute: jo={"icon":"ic_notification","iconColor":"#EA654B","forceShow":true,"vibrate":true}
2020-11-18 20:58:38.992 23504-23623/cz.Menicka.restaurater E/cka.restaurate: Invalid ID 0x00000000.
2020-11-18 20:58:38.992 23504-23623/cz.Menicka.restaurater E/Push_Plugin: execute: Got Resources NotFoundException String resource ID #0x0

@dovydaskukalis
Copy link

Same issue, had to revert to phonegap-plugin-push.

@Sharavanan7944
Copy link

"cordova-support-google-services": {} add this in cordova plugins in package.json.

  1. WIthout this the plugin "cordova-support-google-services" will not be installed.
  2. And without that plugin google-services classpath will not be added to gradle
  3. And finally without the classpath resource gcm_defaultSenderId is not available to push plugin. So this error occurs
"cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-install-referrer-api": {},
      "cordova-plugin-inappbrowser": {},
      "com.cordova.plugins.cookiemaster": {},
      "cordova-plugin-dialogs": {},
      "havesource-cordova-plugin-push": {
        "ANDROID_SUPPORT_V13_VERSION": "28.0.0",
        "FCM_VERSION": "18.+"
      },
      "cordova-support-google-services": {}
    },
    "platforms": [
      "android"
    ]
  }

@erisu
Copy link

erisu commented Jul 28, 2021

I will be closing out this issue as unreproducible in the current release version 2.0.0 and based on ticket description and feedback, it appears the installation guide was skipped.

This plugin does not include cordova-support-google-services because Cordova-Android 9.0.0 and up has integrated support for Google Services Gradle Plugin.

Adding cordova-support-google-services may create conflicting issues with the core platform for Cordova-Android 9.x and up.

Version 1.0.0 original goal was to support Cordova-Android 9.x out-of-the-box without additional configuration. But, to keep support for Cordova-Android 8.1+ users, there were additional setup steps that had to be performed.

It was documented in the installation guide, which you should read here: https://github.com/havesource/cordova-plugin-push/blob/1.0.x/docs/INSTALLATION.md#cordova-android-8x-specifics

Based on the original ticket description and other users' comments, it appears everyone was using plugin version 1.x and/or using Cordova-Android 8.1.0.

It is recommended to upgrade both the platform and plugin to the latest release.

The plugin version 1.x is no longer being maintained.

Cordova-Android has just released 10.0.0 and there are additional releases in the pipeline.

Lastly, as for the plugin, version 3.0.0 is in the making.

@erisu erisu closed this as completed Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants