[Android] onRegister not called, no permissions requested
See original GitHub issueHey guys, I’ve been trying to get this working for quite a while now, but the onRegister
callback never seems to get called, no matter what configuration I try.
I’m using FCM with the following settings:
top-level build.gradle
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
googlePlayServicesVersion = "15.0.1"
androidMapsUtilsVersion = "0.5+"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.0.2'
}
}
allprojects {
repositories {
google()
mavenLocal()
jcenter()
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
AndroidManifest
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<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" />
...
<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.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
and my PushNotification
config
PushNotification.configure({
onError: function(e) {
console.log(e)
},
onRegister: function(token) {
token.os = Platform.OS === 'ios' ? 'ios' : 'android'
api.registerDevice(token)
},
onNotification: function(notification) {
// console.log(notification)
if (Platform.OS === 'ios') notification.finish(PushNotificationIOS.FetchResult.NoData)
},
senderId: SENDER_ID,
permissions: {
alert: true,
badge: true,
sound: true
},
popInitialNotification: true,
requestPermissions: true
})
Everything works well on iOS, and local notifications are working for android.
The problem I am facing is that onRegister
never gets called on android (on device and on emulator) which means that there is no way for me to send remote push notifications.
I am hoping someone can help me solve this issue, or at the very least point me towards methods for debugging why it may not be called.
Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:12
- Comments:23
Top Results From Across the Web
react native - Why isn't a device token being generated?
I can get a local notification to fire on load, and onNotification is being called upon interaction, but no token. I'm not sure...
Read more >react-native-push-notification - npm
React Native Local and Remote Notifications for iOS and Android ... token (android and ios) will requested or not, * - if not,...
Read more >Step by Step guide for Implementing Push Notifications in iOS ...
Specified if permissions (ios) and token (android and ios) will requested or not,. * - if not, you must call PushNotificationsHandler.
Read more >How to use the react-native-push-notification.configure ... - Snyk
To help you get started, we've selected a few react-native-push-notification.configure examples, based on popular ways it is used in public projects.
Read more >Push Notifications - QuickBlox Documentation
Push Notifications provide a way to deliver some information to a user while they are not using your app actively. The following use...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
[Solved my problem with crash]
Fix was basically to set
com.google.android.gms:play-services-gcm
andcom.google.firebase:firebase-messaging
to same versionso my
app/build.gradle
looks like:https://github.com/rebeccahughes/react-native-device-info/issues/463#issuecomment-413313038
on my android device problem was solved to install Google Play Services
also no any error in
onError: function(e) {