nomad-cli / houston

Apple Push Notifications; No Dirigible Required
http://nomad-cli.com
MIT License
2.93k stars 229 forks source link

setting notification.mutable_content = true causes the notification to not be sent #151

Closed avnerbarr closed 3 years ago

avnerbarr commented 7 years ago

Not sure the push isn't sent or isn't arriving or what.

I created a UNNotificationServiceExtension. The push arrived on one of the tries but stopped working after one success.

I removed the mutable_content flag and the push started to be delivered again as expected.

require 'houston'
token = "<67df32a7 8652e486 0d6c604d 4c4d88af 77233059 170d2d4c 2df4d882 36f5fca0>"

pem = "path/to/pushcert.pem"
pw = "1"

APN = Houston::Client.development
APN.certificate = File.read(pem)

# Create a notification that alerts a message to the user, plays a sound, and sets the badge on the app
notification = Houston::Notification.new(device: token)
notification.alert = 'sdakjfl'

# Notifications can also change the badge count, have a custom sound, have a category identifier, indicate available Newsstand content, or pass along arbitrary data.
notification.badge = 57
notification.sound = 'sosumi.aiff'
# notification.category = 'INVITE_CATEGORY'
#notification.content_available = true
notification.mutable_content = true
notification.custom_data = { foo: 'bar' }

# And... sent! That's all it takes.
APN.push(notification)
puts "Error: #{notification.error}." if notification.error
beatrupp commented 7 years ago

I can confirm this bug. I use the command line tool as follows:

apn push “2d6314d238f695bc469dc729566423d6212027b043b5263c80071833a79a9g5e"  -c aps_development.pem  -p -P '{"aps": {"alert": "New push received", "badge": 0, "sound": "", "mutable-content": 1, "category": “myCategory”, "content-available": 1}}'

It works once, then I have to remove the key-value pair "mutable-content":1, otherwise the push is never sent (or received by the device).

tuchangwei commented 5 years ago

I can confirm this bug. I use the command line tool as follows:

apn push “2d6314d238f695bc469dc729566423d6212027b043b5263c80071833a79a9g5e"  -c aps_development.pem  -p -P '{"aps": {"alert": "New push received", "badge": 0, "sound": "", "mutable-content": 1, "category": “myCategory”, "content-available": 1}}'

It works once, then I have to remove the key-value pair "mutable-content":1, otherwise the push is never sent (or received by the device).

@beatrupp Maybe you shouldn't make the two keys exist together mutable-content, content-available, as the document says:

When a remote notification for your app is received, the system loads your extension and calls its didReceive(_:withContentHandler:) method only when both of the following conditions are met:

The remote notification is configured to display an alert.

The remote notification’s aps dictionary includes the mutable-content key with the value set to 1.

Note

You cannot modify silent notifications or those that only play a sound or badge the app’s icon.