dcai / airnotifier

Push Notifications Server for Human Beings.
Other
602 stars 190 forks source link

Feature request: Silent notifications #150

Closed armandzwan closed 7 years ago

armandzwan commented 8 years ago

With APNS you can sent silent notifications. For it to work, we need to set "content-available" : true

in the "aps" dictionary for example:

{
    aps =     {
        "content-available" = 1;
        sound = "";
    };
}

can this be added?

See Table 5-1 https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/TheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH107-SW2

MartinSchultz commented 8 years ago

A quick hack for that is to add it to the push implementations. I added it for testing in the folder "pushservices" in the file apns.py (for Apple Push) and added there the marked line:

item = {} item['content-available'] = 1 <----- this line added, around line 82 if self.sound is not None:

After that my push msg on the app looks like this:

2016-05-28 17:23:44.512 Patchwork[2182:774177] ----- Did receive remote notification: { aps = { alert = ""; "content-available" = 1; sound = ""; }; }

I have yet no idea what to change for Android.

software-mariodiana commented 7 years ago

I submitted a pull request with changes made to implement support for content-available. In the JSON sent in the POST request to AirNotifier, add a new key-value pair:

"content": 1

This will be changed to the proper flag for the APNs.

See: https://github.com/airnotifier/airnotifier/pull/168

software-mariodiana commented 7 years ago

The pull request was accepted and this feature has now been implemented.

dcai commented 7 years ago

Thanks guys!