zo0r / react-native-push-notification

React Native Local and Remote Notifications
MIT License
6.73k stars 2.05k forks source link

Can't configure senderID in example app #1381

Closed riamon-v closed 4 years ago

riamon-v commented 4 years ago

Bug

Hello. I was struggling configure the pushNotification plugin in my own application so I decided to check if it was working on the example app

Onde I launched it I tried localNotifications, working fine. However I wanted to try a remote notification (what i want to do in my own app as well) and filled in the input to configure my FCM senderID. Seems the app crash at this step when I click the button. I investigated a bit and it seems to come from the onRegister function but I can't find what cause the problem exactly. I recently updated the package from 3.1.9 to 3.2.1 and since then it doesn't work anymore. The steps to configure the PushNotifications plugins were working fine in 3.1.9, I could register and receiver notifications as expected

Any idea ?

Environment info

react-native info output:

 System:
    OS: macOS 10.15.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 241.64 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 13.10.1 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK: Not Found
  IDEs:
    Android Studio: 3.6 AI-192.7142.36.36.6308749
    Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_242 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0
    react-native: 0.62.2 => 0.62.2

Library version: 3.2.1

Steps To Reproduce

  1. git clone https://github.com/zo0r/react-native-push-notification.git
  2. cd example
  3. npm install
  4. npx react-native run-android (I had to refactor the android project to AndroidX in android studio to make it work)
  5. configure the FCM senderID in app

Describe what you expected to happen:

  1. Except the example app not to crash

Reproducible sample code

Dallas62 commented 4 years ago

Hi @riamon-v Thanks for the report, I will check ASAP I'm surprise the app crashes, do you see any logs on adb logcat ?

riamon-v commented 4 years ago

I got an error like this on my phone, and my own app, I assume it is the same for the example cause it crashes the exact same time @Dallas62 Screenshot_2020-04-23-16-02-38-641_com miui bugreport

Dallas62 commented 4 years ago

This error is strange, but it seems that Firebase is not initialized

riamon-v commented 4 years ago

This error is strange, but it seems that Firebase is not initialized

Well.. not getting this error in 3.1.9 in my own app, and the example app crashed when trying to configure, so i'm kinda stuck here

Dallas62 commented 4 years ago

This could be due to https://github.com/zo0r/react-native-push-notification/pull/1355/ I will look if we can do something for this in the library; Do you need other services from firebase ?

Take a look at this: https://stackoverflow.com/questions/40081539/default-firebaseapp-is-not-initialized

riamon-v commented 4 years ago

This could be due to #1355 I will look if we can do something for this in the library; Do you need other services from firebase ?

Take a look at this: https://stackoverflow.com/questions/40081539/default-firebaseapp-is-not-initialized

Oh ok I see, have you succeeded to reproduce the bug on the example app ? I don't need any other services from firebase for now, only the cloud messaging part

Dallas62 commented 4 years ago

Actually I don't have time to look at this, I will come back when I looked into it. If you want to solve this issue, you can try to install Firebase in Android (until the initialisation part).

dhoncrisley commented 4 years ago

Same problem here. When I remove the param senderID dont crash, but will work only local. here is my build.gradle implementations

implementation 'com.google.firebase:firebase-core:9.6.1' implementation ('com.google.android.gms:play-services-gcm:11.6.2') { force = true; } implementation 'com.google.android.gms:play-services-ads:19.1.0' the AndroidManifest

`

  <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
  <intent-filter>
  <action android:name="android.intent.action.BOOT_COMPLETED" />
  </intent-filter>
  </receiver>
  <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
  <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService" android:exported="false">
  <intent-filter>
  <action android:name="com.google.android.c2dm.intent.RECEIVE" />
  </intent-filter>
  </service>`
bobbyrinaldy commented 4 years ago

Same problem here. When I remove the param senderID dont crash, but will work only local. here is my build.gradle implementations

implementation 'com.google.firebase:firebase-core:9.6.1' implementation ('com.google.android.gms:play-services-gcm:11.6.2') { force = true; } implementation 'com.google.android.gms:play-services-ads:19.1.0' the AndroidManifest

<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" /> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/> <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService" android:exported="false"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> </intent-filter> </service>

it seems your config is not up to date as mention here https://github.com/zo0r/react-native-push-notification/issues/1380#issuecomment-618357492

dhoncrisley commented 4 years ago

Same problem here. When I remove the param senderID dont crash, but will work only local. here is my build.gradle implementations implementation 'com.google.firebase:firebase-core:9.6.1' implementation ('com.google.android.gms:play-services-gcm:11.6.2') { force = true; } implementation 'com.google.android.gms:play-services-ads:19.1.0' the AndroidManifest <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" /> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/> <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService" android:exported="false"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> </intent-filter> </service>

it seems your config is not up to date as mention here #1380 (comment)

Hi, i have solved the problem with the

This could be due to #1355 I will look if we can do something for this in the library; Do you need other services from firebase ?

Take a look at this: https://stackoverflow.com/questions/40081539/default-firebaseapp-is-not-initialized

my bundle.gradle in root

dependencies {
        classpath("com.android.tools.build:gradle:3.4.2")
        classpath 'com.google.gms:google-services:4.3.3'
    }

my bundle.gradle in module level:

apply plugin: 'com.google.gms.google-services'  //on top
dependencies {
   implementation 'com.google.firebase:firebase-core:9.6.1'//maybe its not necessary?

    implementation 'com.google.firebase:firebase-analytics:17.2.2'

    implementation ('com.google.android.gms:play-services-gcm:17.0.0') { force = true; }

    implementation 'com.google.android.gms:play-services-ads:19.1.0'
}

it solved for me

Dallas62 commented 4 years ago

Cool ! If something is missing on the README feel free to update ;) I will check tomorrow

Dallas62 commented 4 years ago

I just complete the README, you can check it, if it's not clear a PR is welcome 😉

riamon-v commented 4 years ago

@dhoncrisley Did not fix the issue for me. I now have something like:

> Task :app:processDebugGoogleServices FAILED
36 actionable tasks: 3 executed, 33 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it.
   Searched Location:
  /Users/piman/Work/mobile-react-native/android/app/src/nullnull/google-services.json
  /Users/piman/Work/mobile-react-native/android/app/src/debug/google-services.json
  /Users/piman/Work/mobile-react-native/android/app/src/nullnullDebug/google-services.json
  /Users/piman/Work/mobile-react-native/android/app/src/nullnull/debug/google-services.json
  /Users/piman/Work/mobile-react-native/android/app/src/debug/nullnull/google-services.json
  /Users/piman/Work/mobile-react-native/android/app/google-services.json
Dallas62 commented 4 years ago

Hi @riamon-v File google-services.json is missing. The Google Services Plugin cannot function without it.

riamon-v commented 4 years ago

Hi @riamon-v File google-services.json is missing. The Google Services Plugin cannot function without it.

Yeah sorry, I just figured this out