Background of the Houston
HoustonAddress on GitHub: Https://github.com/nomad/Houston, the author Mattt Thompson is, it is inhuman ah, high-yielding, and quality
Houston allows us to debug remote notifications locally and even at the terminal.
Installation
First install in Terminal:
$ gem install houston
I made a mistake the first time I installed it, but the second time I installed it successfully:
...for houston-2.2.31 gem installed
After successful installation, gem list the Execute command can see the Houston and its version number:
You can then execute apn the command:
$ apnerror: undefined method `size‘ for nil:NilClass. Use --trace to view backtrace
Preparing certificates
You need to prepare the certificate file before you can use it formally pem :
Keychain AccessSelect your Push Services certificate and expand the private key file by the small arrow on the left of it
- After selecting these two files, right-click to select
Export 2 items...
- Select
p12 the format and name the exported filecert.p12
- Finally,
p12 turn this file into a pem file
$ openssl pkcs12 -in cert.p12 -out apple_push_notification.pem -nodes -clcerts
If your Keychain Access does not have a Push Services certificate, you may need to download or create one:
1. Login to IPhone Developer Connection Portal (http://developer.apple.com/iphone/manage/overview/index.action) and click on App IDs
2. Create an APP ID that does not use wildcards because the wildcard ID cannot be used for the push notification service
3. Click "Configure" next to the App ID and press the button to produce the push notification license. Generate a signature and upload according to the steps in the wizard, and finally download the generated license
4. Add your aps_developer_identity.cer to Keychain access by double-clicking the. cer file
5. After Push Services the certificate is added pem , proceed to the file.
You can then test the remote notification at the terminal.
Send remote Notifications
The certificate path needs to be specified in the apn command DeviceToken pem .
Normal text
For example, test the normal text notification:
"<d10c67b0 079cfdc0 27b5dd81 2fd537ce 16831f40 ca55fa34 8b14ffde 626435f6>""Hello"
After the successful terminal prompt:
1 push notification sent successfully
Custom parameters
Remote Notification with parameters:
"<d10c67b0 079cfdc0 27b5dd81 2fd537ce 16831f40 ca55fa34 8b14ffde 626435f6>" -c ~/Desktop/apple_push_notification.pem "Hello"-d content-id=42
customizing multiple parameters
Multiple parameters are separated by commas:
"<d10c67b0 079cfdc0 27b5dd81 2fd537ce 16831f40 ca55fa34 8b14ffde 626435f6>" -c ~/Desktop/apple_push_notification.pem "Hello"-d content-id=42,icon=image.png
Silent Notification
"<d10c67b0 079cfdc0 27b5dd81 2fd537ce 16831f40 ca55fa34 8b14ffde 626435f6>" -c ~/Desktop/apple_push_notification.pem -s"" -n
The silent notification is to be sound set to an empty string and to be enabled content_available .
Terminal options available
- '-M ', ' –alert alert ', ' Body of the alert to send in the ' push notification '
- '-B ', ' –badge number ', ' badge number to set with the ' push notification '
- '-S ', ' –sound sound ', ' sound to play with the notification '
- '-y ', ' –category category ', ' Category of notification '
- '-n ', ' –[no]-newsstand ', ' indicates content available for newsstand '
- '-d ', ' –data key=value ', Array, ' Passes Custom data to payload (as comma-delimited "key=value" declarations) '
- '-P ', ' –payload payload ', ' JSON payload for notifications '
- '-e ', ' –environment ENV ', [:p roduction,:d evelopment], ' environment to send push notification (production or development ( Default)) '
- '-C ', ' –certificate certificate ', ' Path to certificate (. Pem) file '
- '-P ', ' –[no]-passphrase ', ' Prompt for a certificate passphrase '
Debug remote notifications locally with Houston