Meteor-Community-Packages / Meteor-Community-Packages/raix-push
raix:push Newbie Manual
@harryward is already working on this.
Since Sep 22, 2015.
- Dominant language
- JavaScript
- Stars
- 505
- Forks
- 191
- PR merge metrics
- No merged PRs in 30d
Description
I just graduated from Newbie status and have utilized Raix in a few applications (one of them currently in apple and google play stores).
It took me a little while to get familiar with the apple certificate generation process, etc but once I did that it was super fast.
If you need any assistance getting raix:push setup or have questions throw them below and i'd be happy to help!
### The MOST IMPORTANT raix:push setup test
Most of you newbies are going to screw up the certificate generation process and its going to drive you crazy. Raix includes this link in his IOS certificate generation tutorial and I highly recommend utilizing this great writeup by Ali.
The final step to generating your key, has you test your .pem files against the sandbox server (or if you want to test production just remove sandbox from the command below:
##### development test command
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert PushChatCert.pem -key PushChatKey.pem
##### production test command
openssl s_client -connect gateway.push.apple.com:2195 -cert PushChatCert.pem -key PushChatKey.pem
Running the test command will prompt you to enter the password you entered when you exported your .p12 file.
##### command response
If you created the certificate and .pem files, etc correctly you are going to get a response like this. If you get an error, it means you did something wrong and your best bet is to start over.
---
New, TLSv1/SSLv3, Cipher is AES256-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1
Cipher : AES256-SHA
Session-ID:
Session-ID-ctx:
Master-Key: XXXXXXXXXXXXXXXXXXXX
Key-Arg : None
Start Time: 1442776397
Timeout : 300 (sec)
Verify return code: 0 (ok)---
If you get this response, you are golden.
### Next Steps
##### Make sure you have a config.push.json
{
"apn": {
"passphrase": "WHATEVER_PASSWORD_YOU_SET_ON_YOUR_P12_KEY",
"key": "ios/apn-production/PushChatKey.pem",
"cert": "ios/apn-production/PushChatCert.pem"
},
"apn-dev": {
"passphrase": "WHATEVER_PASSWORD_YOU_SET_ON_YOUR_P12_KEY",
"key": "iosGp/apn-dev/PushChatKey.pem",
"cert": "iosGp/apn-dev/PushChatCert.pem"
},
"gcm": {
"apiKey": "GET_THIS_FROM_GOOGLE_DEVELOPERS_CONSOLE",
"projectNumber": GET_THIS_FROM_GOOGLE_DEVELOPERS_CONSOLE
},
"production":false,
"badge": true,
"sound": true,
"alert": true,
"vibrate": true
}
##### Create a /server/pushMethods.js file to test
Push.debug = true;Push.allow({
send: function(userId, notification) {
return true; // Allow all users to send
}
});Meteor.methods({
serverNotification: function(text,title) {
var badge = 1
Push.send({
from: 'push',
title: title,
text: text,
badge: badge,
sound: 'airhorn.caf',
payload: {
title: title,
text:text,
historyId: result
},
query: {
// this will send to all users
}
});
},
userNotification: function(text,title,userId) {
var badge = 1
Push.send({
from: 'push',
title: title,
text: text,
badge: badge,
sound: 'airhorn.caf',
payload: {
title: title,
historyId: result
},
query: {
userId: userId //this will send to a specific Meteor.user()._id
}
});
},
});
### FINAL STEPS
##### DEPLOY to blah.meteor server or utilize MODULUS
Your impatient instinct is going to make you jump to the app you have running on localhost and call the method you just created. DO NOT DO THAT.
raix:push testing does not work from your local host
Once you deploy your app to either a meteor or modulus server by running this...
meteor deploy blah.meteor.com
sudo modulus deploy
##### RUN YOUR APP with --mobile-settings
meteor run ios-device --mobile-server blah.meteor.com --production
once that runs its going to open up xCode - - plug in your device to your computer and select it from the available devices. (your device must have a provisioning profile - which is set up in the apple developer center https://developer.apple.com/account.
Once you have the app succesfully launched on your phone, it will prompt you saying 'Blah would like to send you push notifications. If you see this, its a very good sign that this will work. Make sure you click 'YES' and once the app is loaded and everything looks good. CLOSE YOUR APP
You cannot receive a push notification when the app is open on your phone, so whenever your testing make sure your app is closed.
##### Execute your first test!!
1. navigate to your meteor web app (from computer web browser) (whatever you set --mobile-server to earlier is the url you need go to)
2. Open up your browsers developer console and click 'console' and run this command
Meteor.call('serverNotification','test','test')
It'll take a few seconds and you should see a push notification on your phone!!!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.