caffeinalab / ti.goosh

GCM/FCM module for Titanium.
MIT License
52 stars 34 forks source link

Android - silent notifications in background #75

Closed AceMacLoud closed 6 years ago

AceMacLoud commented 7 years ago

Module is working at it should so far - many thanks for that :-) Notifications arrive in the app via GCM or FCM when the app is running in the foreground and pop up as a notification when the app is in the background. I'm having an issue regarding "silent" notifications (like "content-available in iOS) though:

As far as I understand the FCM and Module documentation, notifications shouldn't pop up in Notification Center when the "notification" part of the payload is empty. Additionally it says in the module documentation

If alert is not present, no message is shown in the notification center.

I can't get this to work. No matter how I format the payload - without notification part, without alert & title, a message will always pop up in notification center. If I remove alert and title the message will contain a JSON string of the other fields in the message. I've been using the sample PHP code to send notifications:

$json = [
  "registration_ids" => [
  "cqdjoSNQP44..."
  ],
  "data"    => [
    "data"  => [
      "alert"     => "Testing " . time(),
      "title"     => "The title",
      "vibrate"   => [100,50,50,50,100],
      "badge"     => 1,
      "tag"       => "APP",
    ]
  ]
];

Changing the payload to this will not pop up a notification but will still show it in the status bar as a white circle and will be visible when swiping down notification center:

$json = [
  "registration_ids" => [
  "cqdjoSNQP44..."
  ],
  "data"    => [
    "data"  => [
      "myKey"       => "myVal",
    ]
  ]
];

Am I misunderstanding how this is supposed to work or is something not working as intended? What I'm trying to achieve is a silent notification that delivers data to the app, like content-available on iOS. The user shouldn't see this notification at all.

lawjeremy commented 7 years ago

I am having this same problem. If I set the alert field to an empty string the device shows an empty notification. If I set alert to null the app crashes in the background.

DouglasHennrich commented 6 years ago

I'm having the same problem: photo_2017-11-16_18-17-39

kopiro commented 6 years ago

Something has changed on Android API. We'll debug in this week. Thank you.

DouglasHennrich commented 6 years ago

Any news?

DouglasHennrich commented 6 years ago

What about who doesn't want to update to Ti7 ?

progress44 commented 6 years ago

Here you go ;) @DouglasHennrich

DouglasHennrich commented 6 years ago

Thank you so much!