Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Unexpected / Broken Android Behavior #767

Closed
ericb opened this issue Mar 30, 2016 · 4 comments
Closed

Unexpected / Broken Android Behavior #767

ericb opened this issue Mar 30, 2016 · 4 comments

Comments

@ericb
Copy link
Contributor

ericb commented Mar 30, 2016

A series of strange behavior crops up with Android notifications. I believe the following (and possibly others that I have missed) all directly stem from an update of the Android SDK:
#724
#746
#747

I've not yet narrowed down what lib specifically causes the issues to crop up, nor have I determined if the root cause lies within the plugin code or the SDK itself. I am opening this so that we can move the related issues discussions to a single location and gather more information / tests to narrow down the root issue.

I believe this is likely related to the build-tools specifically, but I have not confirmed just yet. The following are my installed libs with their versions where the problems exist:

screen shot 2016-03-30 at 9 47 20 am

I believe my libs were pre marshmallow support before I updated, but I stupidly did not take a screenshot of my versions pre-updating so I will try to get versions from a working setup to post as well.

Reproduce Scenario (including but not limited to)

Update Android SDK libraries and compile the plugin.

Steps to Reproduce

  1. Run android to update SDK libraries
  2. Add an expected output to the onNotification handler of the plugin.
  3. Recompile the plugin within an app.
  4. Send a notification to the app while the application is closed.
  5. Click the notification.
  6. Notice the onNotification callback is not fired. (the other issues listed above can be experienced as well)

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Android Only
Confirmed 5.x and 6.x experience the same issues. 
4.x is likely affected as well.

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Does not appear to be vendor specific, but I have experienced this on a Oneplus One.

Cordova CLI version and cordova platform version

(likely not dependent, but not necessarily)

cordova 5.3.1
cordova android 4.1.1

Plugin version

1.6.1

Sample Push Data Payload

{
    "registration_ids": ["my device id"],
    "data": {
        "message": "This is a test message"
    }
}

Sample Code that illustrates the problem

n/a

Logs taken while reproducing problem

Plugin logs:

V/PushPlugin(22114): execute: action=init
V/PushPlugin(22114): execute: data=[{"ios":{"badge":true,"sound":true},"android":{"iconColor":"#0000FF","senderID":"------sender_id-------"}}]
V/PushPlugin(22114): execute: jo={"iconColor":"#0000FF","senderID":"------sender_id-------"}
V/PushPlugin(22114): execute: senderID=209176109114
V/PushPlugin(22114): onRegistered: {"registrationId":"-----token-----"}
D/PushPlugin(22114): no icon option
@macdonst
Copy link
Member

First I don't think what is documented here has anything to do with #746 and #747. That has to do with the OS takes over and does not call GCMIntentService.onMessageReceived() when you use the "notification" area of the push payload. This is explained in great detail in this issue in GCM's repo: google/gcm#63.

I have tried to reproduce this problem and I cannot. I've tested on the following devices:

  • OnePlusOne: Cyanogen 12.1.1 (Android 5.1.1)
  • Nexus 5: Android 4.4
  • Nexus 5x: Android N
  • Nexus 6p: Android 6.0.1
  • Nexus 6: Android 5 something, currently charging.

The method that I'm using to test is a node-gcm script:

var gcm = require('node-gcm');
// Replace these with your own values.
var apiKey = "replace with API key";
var deviceID = "my device id";
var service = new gcm.Sender(apiKey);
var message = new gcm.Message();
message.addData('message', 'This is a test message');
service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) {
    if(err) console.error(err);
    else    console.log(response);
});

I am getting the notification event handler invoked when the app is in the foreground. When the app is in the background I see the notification in the shade and when I click on the notification the notification event handler is invoked once the app starts. Then I kill the app and send a notification. I see the notification in the shade, the app is in the foreground. When the app is in the background I see the notification in the shade and when I click on the notification the notification event handler is invoked once the app starts. As and extra bonus, the coldstart value is set to true in this case.

My test environment is:

cordova 6.0.0
cordova android 5.1.0
phonegap-plugin-push 1.6.1

The only difference is my Android SDK Build tools is version 23.0.3 not 23.0.1.

@ericb
Copy link
Contributor Author

ericb commented Mar 30, 2016

Just to document my investigation, it appears the build-tools is not to blame here, I was able to have a working version using the latest SDK, but using an older extras folder with the following versions (note this is quite older and is not using the google play services library directly):

screen shot 2016-03-30 at 1 15 42 pm

After updating the Google Repository to revision 25, the problem occurred again. At first thought that would seem to indicate that being the issue, but I'm not necessarily convinced that's the sole culprit.

@ericb
Copy link
Contributor Author

ericb commented Mar 31, 2016

Update 2: solution

Following up on the previous installations and compatibility, it appears that there is an underlying compatibility issue with some of the installed SDK packages (probably not even necessarily a bug but more something is choosing the wrong version as there are likely multiple).

I've come to this conclusion after multiple tests of packages and installations, and cannot reproduce the issues with a clean install of the SDK with the minimum required packages to build the app with the plugin:

screen shot 2016-03-31 at 9 17 54 am

I recommend anyone else having similar issues to do a fresh install and I am considering this closed as there does not appear to be anything wrong with the plugin directly.

@ericb ericb closed this as completed Mar 31, 2016
@lock
Copy link

lock bot commented Jun 4, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants