globocom / react-native-ua

React Native module for Urban Airship
MIT License
37 stars 33 forks source link

I can't get push notifications from Urban Airship directly [ANDROID] #46

Closed Drey23 closed 7 years ago

Drey23 commented 7 years ago

Hi,

I already followed the instructions and I can get notifications from Firebase directly on Android, but I can't get notifications from Urban Airship directly. I tested sending notifications from Urban webpage, but the app is not getting them. How can I solve this? Is this library working correctly?

rlepinski commented 7 years ago

Read through http://docs.urbanairship.com/reference/push-providers/gcm.html and make sure everything is setup properly. This might be the same issue as http://stackoverflow.com/questions/39456491/android-gcm-server-key-is-not-working-with-urban-airship

Drey23 commented 7 years ago

@rlepinski I already tested with project id, server key and sender id from Firebase and it is not working yet. But, I started debugging the Java (Android) side and I could see that there is an option named "takeoff" setted as "FALSE". Until I know, this option has to be "TRUE" and I can't change it because the methods set and get of this variable are private static. So, I think this is the problem, but I don't know if someone more is getting the same problem on Android.

rlepinski commented 7 years ago

@Drey23 Autopilot is used for takeOff in the plugin. Did you enable user notifications? Can you run the app with verbose logs and check to see if your channel registration has a push registration ID?

Drey23 commented 7 years ago

Yes, I get true when I verify notification permissions. If you are talking about ReactNativeUA.get_channel_id(), I can't use this method because React Native doesn't find it. In fact, if I go to Android side, I can't find this method as well. @rlepinski

rlepinski commented 7 years ago

@Drey23 Can you set developmentLogLevel to VERBOSE in your airshipconfig.properties file and provide some output logs? Make sure to avoid posting any app secrets.

Drey23 commented 7 years ago
undefined is not a function (evaluating '_reactNativeUa2.default.get_channel_id()')
UALib: AirshipService - Received intent: Intent { act=com.urbanairship.push.ACTION_UPDATE_CHANNEL_REGISTRATION /com.urbanairship.AirshipService (has extras) }
/ActionUrl: Enable default action url behaviour -> True
UALib: AirshipService - Starting tasks for intent: com.urbanairship.push.ACTION_UPDATE_CHANNEL_REGISTRATION taskId: 9
UALib: NamedUser - Skipping update. Named user ID trimmed already matches existing named user: user_id
/ReactNativeJS: 'notifications enabled:', true

@rlepinski

rlepinski commented 7 years ago

@Drey23 What is the actual issue you are facing? Channel ID is not released yet, so in order for that to work you have to build from master. I just merged it a day ago.

I need verbose logging from your android device monitor in order to help your push issue. Are you using android studio to run your application? If so I need the logs in the Android Monitor - https://developer.android.com/studio/debug/am-logcat.html

Drey23 commented 7 years ago

The real issue I'm facing is that I can't get push notifications from Urban Airship directly. If I go to Urban Airship dashboard and I send a notification, the app can't get it. But, If I go to Firebase dashboard and I send a notification, the app receives the notification. Why I can't get notifications from Urban Airship directly?

rlepinski commented 7 years ago

I am trying to help you with that but I need output logs to figure out if the SDK is setup and configured properly. Without logs I am unable to help.

Drey23 commented 7 years ago

@rlepinski What kind of message are you waiting for to know if the SDK is set up? I mean, I followed your instructions and it works with Firebase. In fact, I had to add extra steps, because I had to add permissions on Android Manifest to get notifications from Firebase. This is the log I get:

- UALib: Update named user failed with status: 403 This action is not allowed when the app is in server-only mode. - UALib: NamedUserJobHandler - No pending tag group updates. Skipping update. - UALib: InboxJobHandler - Fetch inbox messages response: Response: ResponseBody: { "messages" : [ ], "badge" : 0 } ResponseHeaders: {null=[HTTP/1.1 200 OK], Cache-Control=[no-cache, no-store, must revalidate], Connection=[keep-alive], Content-Type=[application/json;charset=utf-8], Date=[Wed, 15 Feb 2017 22:33:31 GMT], Vary=[Accept-Encoding, User-Agent], X-Android-Received-Millis=[1487197291032], X-Android-Response-Source=[NETWORK 200], X-Android-Selected-Transport=[http/1.1], X-Android-Sent-Millis=[1487197290854], X-N=[S]} ResponseMessage: OK Status: 200 - UALib: Received 0 inbox messages. 02-15 17:21:31.195 1000-3550/com.google.android.gms I/Icing: Indexing * from com.google.android.gms 02-15 17:21:31.199 1000-3550/com.google.android.gms I/Icing: Indexing done **** 02-15 17:21:31.339 14242-14321/com.* E/BluetoothAdapter: Bluetooth binder is null 02-15 17:21:31.339 14242-14321/com. W/System.err: java.lang.NullPointerException 02-15 17:21:31.339 14242-14321/com.W/System.err: at com.learnium.RNDeviceInfo.RNDeviceModule.getConstants(RNDeviceModule.java:95) 02-15 17:21:31.339 14242-14321/com. W/System.err: at com.facebook.react.cxxbridge.JavaModuleWrapper.getConstants(JavaModuleWrapper.java:130) 02-15 17:21:31.339 14242-14321/com. W/System.err: at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 02-15 17:21:31.339 14242-14321/com W/System.err: at android.os.Handler.handleCallback(Handler.java:733) 02-15 17:21:31.339 14242-14321/com. W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95) 02-15 17:21:31.339 14242-14321/com. W/System.err: at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) 02-15 17:21:31.339 14242-14321/com. W/System.err: at android.os.Looper.loop(Looper.java:136) 02-15 17:21:31.339 14242-14321/com. W/System.err: at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) 02-15 17:21:31.339 14242-14321/com. W/System.err: at java.lang.Thread.run(Thread.java:841) 02-15 17:21:31.363 14242-14321/com.* I/ReactNativeJS: Running application "****" with appParams: {"initialProps":{},"rootTag":1}. DEV === true, development-level warning are ON, performance optimizations are OFF 02-15 17:21:31.391 14242-14322/com.* D/ActionUrl: Enable default action url behaviour -> True 02-15 17:21:31.391 14242-14322/com.* D/**** - UALib: NamedUser - Skipping update. Named user ID trimmed already matches existing named user: user_id 02-15 17:21:31.391 14242-14242/com.* D/ - UALib: AirshipService - Received intent: Intent { act=com.urbanairship.push.ACTION_UPDATE_CHANNEL_REGISTRATION cmp=com./com.urbanairship.AirshipService (has extras) } 02-15 17:21:31.391 14242-14300/com.* D/**** - UALib: AirshipService - Starting tasks for intent: com.urbanairship.push.ACTION_UPDATE_CHANNEL_REGISTRATION taskId: 10 02-15 17:21:31.391 14242-14302/com.*** V/**** - UALib: ChannelJobHandler - Performing channel registration. 02-15 17:21:31.391 14242-14302/com.**** V/**** - UALib: ChannelJobHandler - Channel already up to date. 02-15 17:21:31.415 14242-14242/com. W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/graphics/Outline;) 02-15 17:21:31.415 14242-14242/com. I/dalvikvm: Could not find method android.graphics.drawable.Drawable.getOutline, referenced from method com.facebook.react.views.view.ReactViewBackgroundDrawable.getOutline 02-15 17:21:31.415 14242-14242/com. W/dalvikvm: VFY: unable to resolve virtual method 1394: Landroid/graphics/drawable/Drawable;.getOutline (Landroid/graphics/Outline;)V 02-15 17:21:31.415 14242-14242/com. D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 02-15 17:21:31.415 14242-14242/com. I/dalvikvm: Could not find method android.graphics.Outline.setConvexPath, referenced from method com.facebook.react.views.view.ReactViewBackgroundDrawable.getOutline 02-15 17:21:31.415 14242-14242/com. W/dalvikvm: VFY: unable to resolve virtual method 1225: Landroid/graphics/Outline;.setConvexPath (Landroid/graphics/Path;)V 02-15 17:21:31.415 14242-14242/com. D/dalvikvm: VFY: replacing opcode 0x6e at 0x0022 02-15 17:21:31.415 14242-14242/com. I/dalvikvm: Could not find method android.graphics.Outline.setRect, referenced from method com.facebook.react.views.view.ReactViewBackgroundDrawable.getOutline 02-15 17:21:31.419 14242-14242/com. W/dalvikvm: VFY: unable to resolve virtual method 1226: Landroid/graphics/Outline;.setRect (Landroid/graphics/Rect;)V 02-15 17:21:31.419 14242-14242/com. D/dalvikvm: VFY: replacing opcode 0x6e at 0x002a 02-15 17:21:31.455 14242-14322/com. W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactVirtualTextShadowNode 02-15 17:21:31.519 14242-14242/com. D/dalvikvm: GC_FOR_ALLOC freed 658K, 12% free 6143K/6920K, paused 5ms, total 5ms 02-15 17:21:31.575 14242-14321/com. I/ReactNativeJS: 'notifications enabled:', true 02-15 17:21:39.675 14242-14322/com. D/dalvikvm: GC_FOR_ALLOC freed 756K, 12% free 6432K/7308K, paused 5ms, total 7ms 02-15 17:21:40.303 14242-14242/com. D/ - UALib: AirshipService - Received intent: Intent { act=com.urbanairship.analytics.SEND flg=0x4 cmp=com./com.urbanairship.AirshipService (has extras) } 02-15 17:21:40.303 14242-14300/com. D/ - UALib: AirshipService - Starting tasks for intent: com.urbanairship.analytics.SEND taskId: 11 02-15 17:21:40.307 14242-14306/com. V/ - UALib: AnalyticsJobHandler - Received job with action: com.urbanairship.analytics.SEND 02-15 17:21:40.311 14242-14297/com. V/ - UALib: PreferenceDataStore - Saving preference: com.urbanairship.analytics.LAST_SEND value: 1487197300313 02-15 17:21:40.319 14242-14306/com. D/ - UALib: EventApiClient - Sending analytic events. Request: com.urbanairship.http.Request@527f8c6c Events: [{"data":{"time_zone":-18000,"daylight_savings":false,"notification_types":["sound","vibrate"],"session_id":"06a310c7-8773-454d-a464-a542d09e3b20","carrier":"Android","lib_version":"8.2.5","connection_type":"wifi","os_version":"4.4.4","package_version":"1.0"},"event_id":"d2977a53-e7ae-49fa-b472-e04e5157cef0","time":"1487197290.107","type":"app_foreground"}] 02-15 17:21:43.499 717-2726/com.android.vending I/PlayCommon: [65] com.google.android.play.a.g.e(909): Preparing logs for uploading 02-15 17:21:43.499 717-2726/com.android.vending I/PlayCommon: [65] com.google.android.play.a.g.e(911): No file ready to send 02-15 17:21:49.855 14242-14322/com. D/dalvikvm: GC_FOR_ALLOC freed 1116K, 17% free 6496K/7740K, paused 8ms, total 8ms 02-15 17:21:50.907 14242-14306/com. D/ - UALib: EventApiClient - Analytic event send response: Response: ResponseBody: ResponseHeaders: {null=[HTTP/1.1 200 OK], Cache-Control=[max-age=0, no-cache, no-store], Connection=[keep-alive], Content-Type=[application/json], Date=[Wed, 15 Feb 2017 22:33:50 GMT], Expires=[Wed, 15 Feb 2017 22:33:50 GMT], Pragma=[no-cache], Server=[nginx/1.6.2], Vary=[Accept-Encoding], X-Android-Received-Millis=[1487197310910], X-Android-Response-Source=[NETWORK 200], X-Android-Selected-Transport=[http/1.1], X-Android-Sent-Millis=[1487197310777], X-UA-Max-Batch=[500], X-UA-Max-Total=[5120], X-UA-Max-Wait=[604800000], X-UA-Min-Batch-Interval=[60000]} ResponseMessage: OK Status: 200 02-15 17:21:50.907 14242-14306/com. D/ - UALib: Analytic events uploaded. 02-15 17:21:53.007 717-948/com.android.vending I/Finsky: [49] com.google.android.finsky.d.e.run(1151): Replicating app states via AMAS. 02-15 17:21:53.019 717-948/com.android.vending D/dalvikvm: GC_FOR_ALLOC freed 968K, 34% free 4513K/6756K, paused 4ms, total 4ms 02-15 17:21:53.079 717-948/com.android.vending I/Finsky: [49] com.google.android.finsky.d.c.a(313): Completed 0 account content syncs with 0 successful. 02-15 17:21:53.079 717-717/com.android.vending I/Finsky: [1] com.google.android.finsky.services.j.a(148): Installation state replication succeeded.

rlepinski commented 7 years ago

@Drey23 I am looking for some sort of channel registration payload or something about GCM registration ID. I see neither in the logs provided. Could you uninstall the app then rerun it and capture the logs?

Basically there are 2 places that you might have a failure. Either the SDK or platform to fcm/gcm is misconfigured. I am trying to rule out SDK integration side.

Drey23 commented 7 years ago

@rlepinski FCM is working, because I'm getting the notifications from Firebase. Which SDK are you talking about? I just followed your steps.

rlepinski commented 7 years ago

@Drey23 Urban Airship uses FCM as a pipeline to send messages. First the Urban Airship SDK must know what the sender id/project number is and it will register with FCM and send that token up to Urban Airship. When that happens you should see some logs about GCM registration being complete and a channel update/create call with the push registration ID part of the token. If you uninstall/reinstall the app and capture logs for the first run I will be able to see if that part is working. If so, then the issue is most likely Urban Airship delivering the messages to FCM/GCM.

Drey23 commented 7 years ago

@rlepinski I'm sorry, my bad. I was taking the incorrect Api Key from Firebase.

rlepinski commented 7 years ago

@Drey23 Glad you figured it out!