Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal exception when I push notification from Advance REST Client #28

Closed
junweimah opened this issue Nov 23, 2016 · 10 comments
Closed

Fatal exception when I push notification from Advance REST Client #28

junweimah opened this issue Nov 23, 2016 · 10 comments

Comments

@junweimah
Copy link

This is how I pushed it from REST Client

to : https://fcm.googleapis.com/fcm/send
Content-Type: application/json
Authorization:key=my_key
payload : { "data": {
"alert": "Testing",
"title": "This is title test",
"tag":"this is tag",
},
"to" : my_device_token
}

I received the notification on my phone, but my application crashed. This is the log

image

What is the problem? Thanks

@junweimah
Copy link
Author

I have solved the following error by changing the payload and URL to the following :

URL : https://android.googleapis.com/gcm/send
payload :
"data":{
"data":{
"alert": "Testing",
"title": "This is title test",
"tag":"BB",
"id":2,
}
},
"to" : my_device_token

But now however, another problem arise

When I push when my app is opened, I get this empty notification :

screenshot_20161123-122011

When I push when my app is closed, I get 2 notifications. 1 is showing the correct text, one is empty, just like the one i got when my app is open

screenshot_20161123-121944

In both cases, when my app is closed and is opened, in the log file i am getting the correct data in the callback :

image

Why is the notification come in differently when the app is opened and closed?

@progress44
Copy link
Contributor

hi @junweimah. Please check the documentation when sending the payload. It seems like a malformed payload. I tried sending notifications both with the app closed and with it opened before the release and they worked. I'll make some other tests just in case

@junweimah
Copy link
Author

@progress44 Ok I'll do some changes accordingly. thanks.

@progress44
Copy link
Contributor

@junweimah anytime. Let me know if it's fixed

@junweimah
Copy link
Author

I have checked everything and honestly I am not sure whether it's the payload problem.

I pushed using this payload, which is almost the same as the previously try in my second comment in this post:

{
 "data": {
  	"data":{
             "alert": "Testing alert and content",
             "title": "this is title",
             "tag": "bb",
             "vibrate": true,
             "sound": true,
             "id": 2,
    }
 },
   "to" :my_device_token
}

But now I am getting no notification, but a blank alert in the middle of the screen when the app is opened :

img_20161124_111229

For when app is closed, the same still happens, I am getting 2 notifications, one is showing the correct text, one is empty

@junweimah
Copy link
Author

Latest update

Everything is fixed. There are some problems in my other module and I fixed them.

Thanks.

ianko added a commit to ianko/ti.goosh that referenced this issue Jan 20, 2017
Fixes a crash that happens when you don't send a `data` object.

Stack trace: 
```
[INFO]  I/ti.goosh.IntentService: Not showing notification cause missing data.alert
[ERROR] AndroidRuntime: FATAL EXCEPTION: AsyncTask caffeinalab#5
[ERROR] AndroidRuntime: Process: com.fanhero.floridacup, PID: 32621
[ERROR] AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.gson.JsonObject.has(java.lang.String)' on a null object reference
[ERROR] AndroidRuntime:     at ti.goosh.IntentService.parseNotification(IntentService.java:122)
[ERROR] AndroidRuntime:     at ti.goosh.IntentService.onMessageReceived(IntentService.java:54)
[ERROR] AndroidRuntime:     at com.google.android.gms.gcm.GcmListenerService.zzq(Unknown Source)
[ERROR] AndroidRuntime:     at com.google.android.gms.gcm.GcmListenerService.zzp(Unknown Source)
[ERROR] AndroidRuntime:     at com.google.android.gms.gcm.GcmListenerService.zzo(Unknown Source)
[ERROR] AndroidRuntime:     at com.google.android.gms.gcm.GcmListenerService.zza(Unknown Source)
[ERROR] AndroidRuntime:     at com.google.android.gms.gcm.GcmListenerService$1.run(Unknown Source)
[ERROR] AndroidRuntime:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
[ERROR] AndroidRuntime:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
[ERROR] AndroidRuntime:     at java.lang.Thread.run(Thread.java:818)
```
progress44 added a commit that referenced this issue Jan 21, 2017
@bert-w
Copy link

bert-w commented Feb 2, 2017

also had this problem here. Sending the payload with data.data.alert as shown above worked for me as well. This syntax seems really odd...

Can you release this soon?

@progress44
Copy link
Contributor

We kept this syntax to maintain the same data structure with iOS so it will most probably remain the same.

@bert-w
Copy link

bert-w commented Feb 2, 2017

Im sending data on php-side using:

$data = json_encode(
    [
      'to' => $params[ 'registrationid' ],
      'notification' => [
        'title' => 'Welcome to my app',
        'body' => 'The Message',
        'icon' => 'uzb_a',
        'color' => '#c12139',
      ],
      'data' => [
        'data' => [
          'alert' => 'SOMEDATA'
        ]
      ]
    ]
  );

This is the exact data retrieved under TiGoosh.registerForPushNotifications-callback function (Android):
schermafbeelding 2017-02-02 om 16 41 30

This is the exact data retrieved using Ti.Network.registerForPushNotifications-callback function (iOS):
schermafbeelding 2017-02-02 om 16 37 42


Something seems off here

@progress44
Copy link
Contributor

Yeah definitely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants