ostinelli / apnotic

A Ruby APNs HTTP/2 gem able to provide instant feedback.
MIT License
480 stars 96 forks source link

Add mdm notifications support #54

Closed bankair closed 7 years ago

bankair commented 7 years ago

Hi all,

This branch adds support for MDM notifications.

A MDM notification is a nude notification with only the following payload (replace the PushMagicValue string by the correct push magic value sent by the iOS device during the register process):

{ "mdm": "PushMagicValue" }

(see https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/MobileDeviceManagementProtocolRef/3-MDM_Protocol/MDM_Protocol.html#//apple_ref/doc/uid/TP40017387-CH3-SW3 for more details)

For the sake of simplicity (and to avoid mixing up token and magic push), I choose to use two mandatory keywords parameter to build the notification:

connection = Apnotic::Connection.new(cert_path: "apns_certificate.pem", cert_pass: "pass")
notification = Apnotic::MdmNotification.new(token: '0LIZNDLZI34023I', push_magic: '09908NINZD09898')
response = connection.push(notification)

Those notifications serve not other purpose than notifying the device that it's MDM server has pending commands waiting for him to check. The reste of the process (commands check in, and execution) is taken care of by the iOS device and the MDM server.

bankair commented 7 years ago

An additional note: We'll be using this in production in a few days at Appaloosa.io. I'll let you know how it's going ;)

bankair commented 7 years ago

Hey, @ostinelli,

What do you think of that update ? Would you like us to update the README as well in order to merge ?

ostinelli commented 7 years ago

Sorry for the late response. Will be reviewing soon.

ostinelli commented 7 years ago

Can you please squash these commit into a single one, will review when done. And yes, please add a typical usage in the README. Thank you!

bankair commented 7 years ago

@ostinelli : Yep, sure, done. Let me know if you need anything else.

Thanks

bankair commented 7 years ago

@ostinelli : Sorry, I did not see your remark about the README in the first place. I added a section explaining briefly how it work.

Let me know if you need anything else ;)

ostinelli commented 7 years ago

Merged, thank you. This is now released in 1.3.0.

bankair commented 7 years ago

Yay ! Nice. BTW, our fork is working great for us in production.

ostinelli commented 7 years ago

Great. Well, you can start using the official one now ^^_