braze-inc / braze-cordova-sdk

Public repo for the Braze Cordova SDK
https://www.braze.com
Other
21 stars 63 forks source link

Question: Which Branch to use #10

Closed jstoup111 closed 7 years ago

jstoup111 commented 7 years ago

I have an Ionic app that builds to both Android and iOS.

Recently several of my Android users have told me that they have not been receiving any notifications via Android. I know that Appboy has the correct credentials/API key associated because I see updated sessions.

Sending a notification sends the notification out, as previous versions still work and iOS works.

I did update the plugin when iOS10 came out which may have caused the issue.

Which branch should I use that will support Android and iOS10 so my users can receive push notifications again?

radixdev commented 7 years ago

Hi @jstoup111,

Our integration is now completely on the master branch. I have a few questions that'll help us fix this:

  1. How did you upgrade to the newest version?
  2. Can you post any Android logs for when a device should be rendering a push notification?
  3. How are you setting the variables used by the Android plugin? I.e. are you using the cordova plugin add command like cordova plugin add path_to_repo\plugin\ --variable APPBOY_ANDROID_GCM_SENDER_ID=SENDER_ID --variable APPBOY_ANDROID_API_KEY=API_KEY --variable APPBOY_ANDROID_PUSH_REGISTRATION_ENABLED=true\false ?
jstoup111 commented 7 years ago

I used your third option to add the plugin. I removed it and then added the plugin to upgrade.

There are no logs, because it looked like device registration wasn't even working.

After fiddling around with it for awhile I ended up figuring out the issue. It seems like APPBOY_ANDROID_PUSH_REGISTRATION_ENABLED=true doesn't register the device. I had to register for push manually and then call AppboyPlugin.registerAppboyPushMessages(deviceToken); before it would register the device. So the issue just seems to be registering automatically (which doesn't seem to happen) and would explain why some devices that upgraded didn't have an issue, but new installs did. It would also explain why they started working after I manually registered for push messages.

radixdev commented 7 years ago

I definitely want to look more into why APPBOY_ANDROID_PUSH_REGISTRATION_ENABLED=true isn't registering push. I can't reproduce that behavior on my end.

  1. In your built app, can you share the contents of your /res/values/appboy.xml file?
  2. Are you registering for push via GCM or FCM?
  3. Can you turn on debug logging and post the entirety of the logcat output after you start a fresh run of the app?

Thanks for your help.

jstoup111 commented 7 years ago
<?xml version='1.0' encoding='utf-8'?>
<resources>
    <string name="com_appboy_api_key" translatable="false">MyAppboyApiKey</string>
    <bool name="com_appboy_push_gcm_messaging_registration_enabled">true</bool>
    <string name="com_appboy_push_gcm_sender_id" translatable="false">MySenderId</string>
    <bool name="com_appboy_handle_push_deep_links_automatically">true</bool>
</resources>

I am registering for push via GCM.

I can send you the logcat output if you can show me where I should put that code. Should I go in this method?

protected void pluginInitialize() {

radixdev commented 7 years ago

That method would work, thank you.

jstoup111 commented 7 years ago

Sorry for the delay got slammed with other things.

12-13 16:37:49.058  1679  1679 I BackupManagerService: Package com.yazda.yazda_ios not installed; dropping from full backup
12-13 16:37:59.793  1679  1776 W PackageParser: Ignoring duplicate uses-permissions/uses-permissions-sdk-m: com.yazda.yazda_ios.permission.C2D_MESSAGE in package: com.yazda.yazda_ios at: Binary XML file line #30
12-13 16:38:01.190  1679  1776 I PackageManager.DexOptimizer: Running dexopt (dex2oat) on: /data/app/vmdl70934585.tmp/base.apk pkg=com.yazda.yazda_ios isa=x86_64 vmSafeMode=false debuggable=true oatDir = /data/app/vmdl70934585.tmp/oat
12-13 16:38:05.782  1679  1776 W PackageManager: Unknown permission com.sec.android.provider.badge.permission.READ in package com.yazda.yazda_ios
12-13 16:38:05.782  1679  1776 W PackageManager: Unknown permission com.sec.android.provider.badge.permission.WRITE in package com.yazda.yazda_ios
12-13 16:38:05.782  1679  1776 W PackageManager: Unknown permission com.htc.launcher.permission.READ_SETTINGS in package com.yazda.yazda_ios
12-13 16:38:05.782  1679  1776 W PackageManager: Unknown permission com.htc.launcher.permission.UPDATE_SHORTCUT in package com.yazda.yazda_ios
12-13 16:38:05.782  1679  1776 W PackageManager: Unknown permission com.sonyericsson.home.permission.BROADCAST_BADGE in package com.yazda.yazda_ios
12-13 16:38:05.782  1679  1776 W PackageManager: Unknown permission com.sonymobile.home.permission.PROVIDER_INSERT_BADGE in package com.yazda.yazda_ios
12-13 16:38:05.782  1679  1776 W PackageManager: Unknown permission com.anddoes.launcher.permission.UPDATE_COUNT in package com.yazda.yazda_ios
12-13 16:38:05.782  1679  1776 W PackageManager: Unknown permission com.majeur.launcher.permission.UPDATE_BADGE in package com.yazda.yazda_ios
12-13 16:38:05.782  1679  1776 W PackageManager: Unknown permission com.huawei.android.launcher.permission.CHANGE_BADGE in package com.yazda.yazda_ios
12-13 16:38:05.782  1679  1776 W PackageManager: Unknown permission com.huawei.android.launcher.permission.READ_SETTINGS in package com.yazda.yazda_ios
12-13 16:38:05.783  1679  1776 W PackageManager: Unknown permission com.huawei.android.launcher.permission.WRITE_SETTINGS in package com.yazda.yazda_ios
12-13 16:38:05.800  1679  1776 V BackupManagerService: restoreAtInstall pkg=com.yazda.yazda_ios token=1 restoreSet=0
12-13 16:38:05.810  2612  3343 I IntentFilterIntentService: Verifying IntentFilter. verificationId:0 scheme:"https" hosts:"bnc.lt" package:"com.yazda.yazda_ios".
12-13 16:38:05.886  2612  3345 D PackageBroadcastService: Received broadcast action=android.intent.action.PACKAGE_ADDED and uri=com.yazda.yazda_ios
12-13 16:38:05.988  2612  3356 D k       : Processing package: com.yazda.yazda_ios
12-13 16:38:06.008  2612  3356 D GassUtils: Found app info for package com.yazda.yazda_ios:761. Hash: 72e9a4cd4c58aa84eaaceb190b80e3810d44288628a56d447b5f0771e9151f57
12-13 16:38:06.008  2612  3356 D k       : Found info for package com.yazda.yazda_ios in db.
12-13 16:38:06.162  2645  3365 I UpdateIcingCorporaServi: Updating corpora: APPS=com.yazda.yazda_ios, CONTACTS=MAYBE
12-13 16:38:06.293  2612  3357 I SingleHostAsyncVerifier:   a: "com.yazda.yazda_ios"
12-13 16:38:06.819  1679  2425 I ActivityManager: START u0 {act=android.intent.action.MAIN flg=0x10000000 cmp=com.yazda.yazda_ios/.MainActivity} from uid 0 on display 0
12-13 16:38:06.869  1679  2432 I ActivityManager: Start proc 3399:com.yazda.yazda_ios/u0a57 for activity com.yazda.yazda_ios/.MainActivity
12-13 16:38:07.617  3399  3466 D Appboy v1.15.3 .bo.app.k: Making request to [https://dev.appboy.com/api/v2/data], with headers: [(Content-Type / application/json), (X-Appboy-Device-Identifier / 4a46f5d5-2f2d-4bee-8568-cad6c379e2d0), (Accept-Encoding / gzip, deflate)] and JSON parameters: [{"extras":{},"environment":{"sdk_version":"1.15.3","now":1.481672287611E9,"version_code":761,"version_name":"1.2.0","package_name":"com.yazda.yazda_ios","no_acks":true},"only_respond_with":["inapp"]}]
12-13 16:38:07.617  3399  3475 D Appboy v1.15.3 .bo.app.k: Making request to [https://dev.appboy.com/api/v2/data], with headers: [(Content-Type / application/json), (X-Appboy-Device-Identifier / 4a46f5d5-2f2d-4bee-8568-cad6c379e2d0), (Accept-Encoding / gzip, deflate)] and JSON parameters: [{"extras":{"sessions":[{"guid":"5114359b-299b-468d-904e-7dbb610e3171","start_time":1.481672287547E9,"new":true}],"device":{"android_version":23,"abi":"x86_64","carrier":"Android","model":"Android SDK built for x86_64","locale":{"language":"en","country":"US"},"time_zone":"America\/Denver","display":{"resolution_height":1776,"resolution_width":1080,"x_dpi":480,"y_dpi":480,"density_default":480}},"user":{}},"environment":{"sdk_version":"1.15.3","now":1.481672287617E9,"version_code":761,"version_name":"1.2.0","package_name":"com.yazda.yazda_ios","config_time":"0","no_acks":true},"only_respond_with":["triggers"]}]
12-13 16:38:07.871  1679  2429 I WindowManager: Switching to real app window: Window{b1652f7 u0 com.yazda.yazda_ios/com.yazda.yazda_ios.MainActivity}
12-13 16:38:07.882  3399  3399 I Appboy v1.15.3 .com.appboy.AppboyGcmReceiver: Received broadcast message. Message: Intent { act=com.google.android.c2dm.intent.REGISTRATION flg=0x10 pkg=com.yazda.yazda_ios cmp=com.yazda.yazda_ios/com.appboy.AppboyGcmReceiver (has extras) }
12-13 16:38:08.160  1679  1736 I ActivityManager: Displayed com.yazda.yazda_ios/.MainActivity: +1s304ms
12-13 16:38:10.705  3399  3519 V info    : Open sqlite db: /data/user/0/com.yazda.yazda_ios/databases/yazda.db
12-13 16:38:10.814  3399  3399 I chromium: [INFO:CONSOLE(175)] "OPEN database: yazda.db", source: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js (175)
12-13 16:38:10.912  3399  3399 I chromium: [INFO:CONSOLE(179)] "OPEN database: yazda.db - OK", source: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js (179)
12-13 16:38:10.932  3399  3399 I chromium: [INFO:CONSOLE(80)] "DB opened: yazda.db", source: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js (80)
12-13 16:38:12.726  3399  3399 I chromium: [INFO:CONSOLE(21157)] "TypeError: [yazda Error] Cannot read property 'user' of undefined
12-13 16:38:12.726  3399  3399 I chromium: [INFO:CONSOLE(31)] "Error: [yazda Error] Cannot read property 'user' of undefined", source: file:///android_asset/www/app/blocks/logger/logger.js (31)
12-13 16:38:12.733  3399  3399 I chromium: [INFO:CONSOLE(21157)] "TypeError: [yazda Error] Cannot read property 'user' of undefined
12-13 16:38:12.733  3399  3399 I chromium: [INFO:CONSOLE(31)] "Error: [yazda Error] Cannot read property 'user' of undefined", source: file:///android_asset/www/app/blocks/logger/logger.js (31)
12-13 16:40:17.608  3399  3399 I chromium: [INFO:CONSOLE(203)] "!!!!! client.owner.getToken.then -- > user --> [object Object]!!!!!", source: file:///android_asset/www/app/yazda-api/token.js (203)
12-13 16:40:18.077  3399  3463 D Appboy v1.15.3 .bo.app.k: Making request to [https://dev.appboy.com/api/v2/data], with headers: [(X-Appboy-User-Identifier / 1), (Content-Type / application/json), (X-Appboy-Device-Identifier / 4a46f5d5-2f2d-4bee-8568-cad6c379e2d0), (Accept-Encoding / gzip, deflate)] and JSON parameters: [{"extras":{"sessions":[{"guid":"5114359b-299b-468d-904e-7dbb610e3171","start_time":1.481672287547E9,"end_time":1.481672417967E9}],"device":{},"user":{}},"environment":{"sdk_version":"1.15.3","now":1.481672418077E9,"version_code":761,"version_name":"1.2.0","package_name":"com.yazda.yazda_ios","no_acks":true},"only_respond_with":[]}]
12-13 16:40:18.100  3399  3657 D Appboy v1.15.3 .bo.app.k: Making request to [https://dev.appboy.com/api/v2/data], with headers: [(X-Appboy-User-Identifier / 1), (Content-Type / application/json), (X-Appboy-Device-Identifier / 4a46f5d5-2f2d-4bee-8568-cad6c379e2d0), (Accept-Encoding / gzip, deflate)] and JSON parameters: [{"extras":{"sessions":[{"guid":"7a8a4319-e65b-4d5b-90be-d6ff34a9f2a2","start_time":1.481672418071E9,"events":[{"n":"ut","d":{"new":"1"},"t":1.481672418073E9}],"new":true}],"device":{"android_version":23,"abi":"x86_64","carrier":"Android","model":"Android SDK built for x8

Here's the payload I'm sending from Rails to this device (which I did and would be in the logs if my app received it).

{:apple_push=>{:alert=>{:body=>"Joe Lathey has invited you to a new adventure.", :title=>"Going for a sick road ride OMG yes super long title let's see if it works"}, :sound=>"yazda_alert.caf", :custom_uri=>nil, :asset_url=>nil, :asset_file_type=>"png", :extra=>{:notification_type=>"adventure"}}, :android_push=>{:alert=>"Joe Lathey has invited you to a new adventure.", :title=>"Going for a sick road ride OMG yes super long title let's see if it works", :custom_uri=>nil, :collapse_key=>"adventure", :extra=>{:sound=>"yazda_alert"}}}

If I call AppboyPlugin.registerAppboyPushMessages(deviceToken); in my code it'll start receiving notifications otherwise I never get anything. Which is totally fine with my workflow, but something funky is going on somewhere

radixdev commented 7 years ago

Thanks again for the help! We have an update to the plugin coming soon that will contain any fix to what we discover here.

  1. Is this running on an emulator? If so, can you run it again from a device? Emulators don't support push notifications.
  2. Where in pluginInitialize() did you place the debug logging line? Sorry for not being clear before, but it should be on the first line, before anything else, so we can see any sdk logs generated in Appboy.getInstance().
  3. Can you re-run the app and obtain new logs given the previous two points? Specifically, I'm looking for any lines containing "com.appboy.configuration.CachedConfigurationProvider" coming from the app.

Thanks, Julian

jstoup111 commented 7 years ago

Yes it was running on an emulator. The emulator has the Google SDK Api's integrated so it does support push notifications. If I put that call I mentioned earlier I start receiving the notifications.

I did put the call on the very first line.

If you give me a specific command to run I can get those logs.

I ran adb logcat | grep -i 'yazda' so it may have missed some of the logs you were interested in.

radixdev commented 7 years ago

For a bit of context, our automatic push registration uses an older style of GCM registration to work that relies on having the Google Play Store installed on the device. Due to this, emulators don't work with our automatic push integration since they don't have the play store installed; my apologies for misspeaking and the confusion there before. Since our push registration doesn't use the play services Api's, I believe this is why our automatic push registration isn't working in your testing.

Moving forward:

  1. Can you run the app on a physical device? This will give us a better signal as to why your users aren't receiving push on their devices.
  2. Can you walk me through your testing procedure? I.e. are you doing a fresh install -> setting the user id -> then sending a push notification, etc.
  3. For the exact command, try running the command below (be sure to include the backtick ` in the command and replace your package name with the placeholder).
    adb logcat | grep `adb shell ps | grep YOUR_PACKAGE_NAME | cut -c10-15`

    Some of the Appboy logs must have gotten missed due to not having "yazda" in the name. Also, the first line of the logs from our sdk should mention com_appboy_disable_uil_image_cache. Please include them all.

  4. When you receive a push on a physical device, can you step through the AppboyGcmReceiver in a debugger and see if the intent received matches what you expect? We log each received intent in the AppboyGcmReceiver but we should be sure there's nothing amiss there.

Thank you.

radixdev commented 7 years ago

Hey @jstoup111 ,

I'm closing this issue for now. Please let me know if you continue to have issues and we'll debug further.