urbanairship / react-native-airship

Airship React Native module
Other
87 stars 62 forks source link

Android: Not updating the Device token #140

Closed wpconsulate closed 6 years ago

wpconsulate commented 6 years ago

I have Integrated the iOS/Android SDK's both are integrated fine. They were working a few days back but recently Android stopped registering the Push Token for device. It is creating Channel and adding Tag for the record but isn't adding the device token.

Screenshot for Ref: http://prntscr.com/kg39yj

Preliminary Info

I'm using

my Package.json dependencies looks like this "dependencies": { "expo": "^28.0.0", "jsonq": "^1.1.0", "moment": "^2.22.2", "react": "16.3.1", "react-native": "https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz", "react-native-datepicker": "^1.7.2", "react-native-elements": "^0.19.1", "react-native-fabric": "0.4.1", "react-native-google-analytics": "^1.3.2", "react-native-keyboard-aware-scroll-view": "^0.5.0", "react-native-masked-text": "^1.7.2", "react-native-picker-select": "^3.1.3", "react-navigation": "^2.5.5", "urbanairship-react-native": "^1.6.2" }

Report

What unexpected behavior are you seeing?

It is not adding GCMId for Android device

What is the expected behavior?

ℹ it should add GCM Id for device token just fine

What are the steps to reproduce the unexpected behavior?

ℹ I don't know how we can reproduce, since It was working earlier and I haven't changed anything in Android project and react native code can't be an issue since ios device tokens are being added successfully

Do you have logging for the issue?

Following is the log from Android Studio

rlepinski commented 6 years ago

Are you providing a GCM sender ID in the config ? We will need verbose logs. You can enable it by setting developmentLogLevel to VERBOSE in you airship config.

Our 2.0 version of the module using FCM now. If you update, you are required to provide a google-services.json file. The steps are oultined in the README.

wpconsulate commented 6 years ago

above log was already from setting developmentLogLevel to VERBOSE and about gcmSender that is already set in airshipconfig.properties file. But in all Logs I do not see any entry for gcmSender. additionally I see these logs

08-08 23:25:25.494 28759-29114/com.petmeds1800.androidApp I/petmeds - UALib: Channel registration succeeded with status: 200 08-08 23:25:25.504 28759-28759/com.petmeds1800.androidApp D/petmeds - UALib: ReactAirshipReceiver - Received intent with action: com.urbanairship.push.CHANNEL_UPDATED 08-08 23:25:25.506 28759-28759/com.petmeds1800.androidApp E/petmeds - UALib: Unable to emit events. React Instance Manager is unavailable.

For Full Logs please check this gist https://gist.github.com/wpconsulate/e4dd2c5d76d560e25b26142170d9e0df

I can try updating the plugin

wpconsulate commented 6 years ago

Updating the plugin won't work since it requires me to upgrade the gradle and other play gcm services which breaks a lot of things

rlepinski commented 6 years ago

@wpconsulate The logs you are posting show the log level being set to DEBUG, if we had verbose we would see the payloads the Channel Registration is sending to verify where the issue is.

wpconsulate commented 6 years ago

@rlepinski those are logs from Verbose let me post updated log with screenshots

rlepinski commented 6 years ago

@wpconsulate Airship log level: 3, 3 = DEBUG.

wpconsulate commented 6 years ago

@rlepinski Please check this Verbose Logs http://prntscr.com/kh5749 Find logs under this gist https://gist.github.com/wpconsulate/b4f3e42c19344fb84b54939a2356c3a9

rlepinski commented 6 years ago

@wpconsulate You cant just set "VERBOSE" in logcat and get verbose logs from UA. You need to set developmentLogLevel = VERBOSE in your airshipconfig. These are still just debug logs.

wpconsulate commented 6 years ago

@rlepinski I have added the developmentLogLevel = VERBOSE un airshipconfig.properties file and updated the log here https://gist.github.com/wpconsulate/b4f3e42c19344fb84b54939a2356c3a9

Please let me know if that helps?

wpconsulate commented 6 years ago

@rlepinski I firgured out that no matter what I send in UrbanAirship.setUserNotificationsEnabled(true); -> true or false the SDK always make call to UA server with "opt_in":false,

here are the logs from the app when we toggle Push Notifications

08-13 13:58:24.458 17266-17467/com.petmeds1800.androidApp I/ReactNativeJS: Opt Status: 08-13 13:58:24.461 17266-17467/com.petmeds1800.androidApp I/ReactNativeJS: true 08-13 13:58:24.469 17266-17351/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: PreferenceDataStore - Saving preference: com.urbanairship.push.USER_NOTIFICATIONS_ENABLED value: true 08-13 13:58:24.496 17266-17266/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: AirshipService - Received intent: Intent { act=RUN_JOB cmp=com.petmeds1800.androidApp/com.urbanairship.job.AirshipService (has extras) } 08-13 13:58:24.497 17266-18924/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: AirshipService - Running job: JobInfo{action=ACTION_UPDATE_CHANNEL_REGISTRATION, id=5, extras='{}', airshipComponentName='com.urbanairship.push.PushManager', isNetworkAccessRequired=true, initialDelay=0, persistent=false} 08-13 13:58:24.498 17266-17484/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: PushManagerJobHandler - Performing channel registration. 08-13 13:58:24.500 17266-17484/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: PushManagerJobHandler - Should update registration. Channel registration payload has changed. 08-13 13:58:24.501 17266-17484/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: ChannelApiClient - Updating channel with payload: {"identity_hints":{"user_id":"oXGZJ703QOGfmbbIIzGpSA"},"channel":{"background":false,"timezone":"Asia\/Kolkata","set_tags":true,"device_type":"android","opt_in":false,"locale_language":"en","locale_country":"GB","tags":["GARYK54"]}} 08-13 13:58:24.527 17266-17266/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: AirshipService - Received intent: Intent { act=RUN_JOB cmp=com.petmeds1800.androidApp/com.urbanairship.job.AirshipService (has extras) } 08-13 13:58:24.530 17266-18924/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: AirshipService - Running job: JobInfo{action=ACTION_UPDATE_CHANNEL_REGISTRATION, id=5, extras='{}', airshipComponentName='com.urbanairship.push.PushManager', isNetworkAccessRequired=true, initialDelay=0, persistent=false} 08-13 13:58:26.754 17266-17484/com.petmeds1800.androidApp I/PetMeds4Vets - UALib: Channel registration succeeded with status: 200 08-13 13:58:26.756 17266-17351/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: PreferenceDataStore - Saving preference: com.urbanairship.push.LAST_REGISTRATION_PAYLOAD value: {"identity_hints":{"user_id":"oXGZJ703QOGfmbbIIzGpSA"},"channel":{"background":false,"timezone":"Asia\/Kolkata","set_tags":true,"device_type":"android","opt_in":false,"locale_language":"en","locale_country":"GB","tags":["GARYK54"]}} 08-13 13:58:26.764 17266-17266/com.petmeds1800.androidApp D/PetMeds4Vets - UALib: ReactAirshipReceiver - Received intent with action: com.urbanairship.push.CHANNEL_UPDATED 08-13 13:58:26.779 17266-17351/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: PreferenceDataStore - Saving preference: com.urbanairship.push.LAST_REGISTRATION_TIME value: 1534148906755 08-13 13:58:26.795 17266-17484/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: Job - Finished: JobInfo{action=ACTION_UPDATE_CHANNEL_REGISTRATION, id=5, extras='{}', airshipComponentName='com.urbanairship.push.PushManager', isNetworkAccessRequired=true, initialDelay=0, persistent=false} with result: 0 08-13 13:58:26.796 17266-17484/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: PushManagerJobHandler - Performing channel registration. 08-13 13:58:26.796 17266-18924/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: AirshipService - Component finished job with startId: 1 08-13 13:58:26.797 17266-17484/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: PushManagerJobHandler - Channel already up to date. Job - Finished: JobInfo{action=ACTION_UPDATE_CHANNEL_REGISTRATION, id=5, extras='{}', airshipComponentName='com.urbanairship.push.PushManager', isNetworkAccessRequired=true, initialDelay=0, persistent=false} with result: 0 08-13 13:58:26.797 17266-18924/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: AirshipService - Component finished job with startId: 2

So something wrong in UA SDK (Android) here because RN code looks good and works fine ( for iOS )

Let me know your Ideas on this?

rlepinski commented 6 years ago

@wpconsulate I do not think its an issue with the UA SDK but rather something interfering with Google's GCM registration. Your channel is opted out because it does not contain a registration token.

This line is not returning the token - https://github.com/urbanairship/android-library/blob/9.0.6/urbanairship-sdk/src/main/java/com/urbanairship/push/gcm/GcmPushProvider.java#L47. Could you provide the output of ./gradlew app:dependencies. You said it use to work, do you remember what changed when it stopped?

wpconsulate commented 6 years ago

@rlepinski below is the output of ./gradlew app:dependencies https://gist.github.com/wpconsulate/b9a8586dd7883fdde3f26e8de1ba685d

Also nothing really have been changed earlier I just updated the he Long Server key from Firebase http://prntscr.com/ki4ajp into UA Api Key http://prntscr.com/ki4b09

nothing else was done on UA SDK setup, except couple of times npm install for module on React

rlepinski commented 6 years ago

@wpconsulate could you try disabling expo's GcmRegistrationIntentService ? I wonder if its a race condition in the GCM packages

wpconsulate commented 6 years ago

okay I can try that give me sometime

rlepinski commented 6 years ago

Expos integration is a bit different than what I would expect, but I believe you can accomplish disabling that service by adding this to your AndoridManifest.xml in the application section:

 <service
      android:name="host.exp.exponent.gcm.GcmRegistrationIntentService"
      android:enabled="false"
      android:exported="false">
    </service>

You will know that its disabled when you no longer see the log line that starts with ExponentNotificationIntentService: gcm Registration Token:. I am just trying to rule out possibilities so we can find the root cause. If you are able to share a project with me that reproduces the issue that would be very helpful.

wpconsulate commented 6 years ago

yes disabled using

<service
      android:name=".gcm.GcmRegistrationIntentService"
        android:enabled="false"
      android:exported="false">
    </service>
wpconsulate commented 6 years ago

@rlepinski Nope still not working https://gist.github.com/wpconsulate/32168993232e30e90de80ba7b952e233

and yes we no more see ExponentNotificationIntentService: gcm Registration Token: but still no token in UA account

rlepinski commented 6 years ago

@wpconsulate Well, I guess thats a good thing because if that was the issue it would be been difficult to work around.

I think I need a project to reproduce the issue. Are you comfortable sharing something with me? I could provide my email so you can avoid sharing it public.

wpconsulate commented 6 years ago

@rlepinski yeah sounds good, Project is on with github ( private) I can provide you access to the Project if you need? I meant on your github ID. or if you prefer any other account let me know

wpconsulate commented 6 years ago

@rlepinski Also I noticed that, even after inital App load if I try to toggle notifications it doesn't make any update on UA account. I guess that is because log shows

08-13 22:33:59.541 16111-16378/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: PushManagerJobHandler - Performing channel registration. 08-13 22:33:59.543 16111-16378/com.petmeds1800.androidApp V/PetMeds4Vets - UALib: PushManagerJobHandler - Channel already up to date.

rlepinski commented 6 years ago

@wpconsulate rlepinski is my gh user.

The CRA behavior is all working as expected. The GCM registration piece is broken for whatever reason.

wpconsulate commented 6 years ago

provided you access on the repo

wpconsulate commented 6 years ago

let me know if I can help in quick setup? but I guess you are the expert :)

rlepinski commented 6 years ago

@wpconsulate I am sure I will need help setting it up. Can we continue this discussion in a private issue on your project?

wpconsulate commented 6 years ago

yes sure let's get in touch there

Canedo commented 6 years ago

Hello guys!

Is there any news on this issue? We are facing a "similar issue" here on our application but we are having problems trying to reproduce it on a reliable way, so any extra input for this particular issue may be applicable to our apps.

Hope you guys can find out any positive outcome.

wpconsulate commented 6 years ago

@Canedo please share your app/build.gradle file in order to be sure of the similar issue

wpconsulate commented 6 years ago

@rlepinski Thanks you are life saver :)

Canedo commented 6 years ago

I cannot share all app/build.gradle, but i can show some dependencies but i dont know its gonna be enough.

dependencies {
    ...

    //Firebase dependencies
    implementation "com.google.android.gms:play-services-base:12.0.1"
    implementation "com.google.firebase:firebase-core:12.0.1"
    implementation "com.google.firebase:firebase-perf:12.0.1"
    ...
    // Urban Airship SDK
    implementation "com.google.android.gms:play-services-gcm:12.0.1"
    implementation "com.google.firebase:firebase-appindexing:12.0.1"
    implementation 'com.urbanairship.android:urbanairship-sdk:9.0.2'
    implementation 'com.facebook.react:react-native:+'

    ...
    implementation "com.google.android.gms:play-services-analytics:12.0.1"
    implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.8.5'
    implementation 'com.android.support:percent:27.1.1'
    ////////////////////////////////

    // React native Admob
    implementation "com.google.android.gms:play-services-ads:12.0.1"
    ...
}

configurations.all {
    resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    resolutionStrategy.force "com.google.android.gms:play-services-base:12.0.1"
    resolutionStrategy.force "com.google.android.gms:play-services-maps:12.0.1"
    resolutionStrategy.force "com.google.android.gms:play-services-gcm:12.0.1"
    resolutionStrategy.force "com.google.android.gms:play-services-auth:12.0.1"
    resolutionStrategy.force "com.google.android.gms:play-services-location:12.0.1"
    resolutionStrategy.force "com.google.android.gms:play-services-analytics:12.0.1"
    resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.8.1'
    resolutionStrategy.force 'com.squareup.okhttp3:logging-interceptor:3.8.1'
}
rlepinski commented 6 years ago

It was due to an out of date version of GPS.

@Canedo I do not want this to become a catch all for everyone. Please open a new issue explaining how your issue is similar.