How can I send iOS notifications using the Meteor app?

I was unable to find a comprehensive tutorial for sending push notifications from the Meteor app. I understand that Meteor works using node.js, so I follow this highly scientific and recommended tutorial https://blog.engineyard.com/2013/developing-ios-push-notifications-nodejs , but to no avail; when I deploy my application, it loads, but the website does not respond to requests (and if there are no errors during the deployment, I don’t see where the problem is, although I believe that this is due to the way I organize my files).

I have uploaded and uploaded all the certificates appropriately in the instruction manual. I used their sample application to get the identifier of my test device correctly. I just can’t understand where to place additional files and dependencies set by the Meteor folder configuration correctly. How should it differ from the structure in the textbook (in other words, should this structure be placed inside a folder in the .meteor folder of my application)?

I think the main problem is that Meteor just structure its applications differently than regular node.js applications, and therefore I need to place these certificates and dependencies in a specific folder, and not just in the main application folder with application.html , application.js and application.css .

+8
meteor apple-push-notifications
source share
3 answers

We use the npm apn package with our Meteor app. We looked at the apnagent (because of the same textbook), but went with the apn because of its greater popularity. Although apnagent should also work well in your Meteor application, you can try apn only for troubleshooting.

We install it on the server side, like this ...

 var apn = Meteor.require("apn"), path = Npm.require('path'), apnOptions = Meteor.settings.apnOptions || {}, alertSound = apnOptions.sound || "alert.aiff", apnConnection // default apn connection options apnOptions = _.extend({ cert: path.join(appRootPath, "private", "cert.pem"), key: path.join(appRootPath, "private", "key.pem"), }, apnOptions) apnConnection = new apn.Connection(apnOptions) 

... and use it as follows:

  sendAppleNotifications: function (alert, url, pushIds) { var note = new apn.Notification() // expires 1 hour from now note.expiry = Math.floor(Date.now() / 1000) + 3600 note.sound = alertSound note.alert = alert note.payload = {'url': url} _.each(pushIds, function (token) { var device = new apn.Device(token) apnConnection.pushNotification(note, device) }) return {success:'ok'} }, // end sendAppleNotifications 

Please note that Meteor.require activated by the npm meteor npm , which you can read here . Alternatively, you can simply put your code that uses the apn package in your own Meteor package and use Npm.require as @GeoffreyBooth .

==

June 20, 2015 - Update

I recently answered a question about device tokens; hope these resources are helpful:

+14
source share

Using Cordova PushPlugin , you will need:

  • Minimize your own integration with the Meteor user model so you can choose which users to send your push notifications to.
  • Create your own certificates
  • .pem store related .pem files and other authorization files.

This is actually quite a bit of work.

raix:push "solves" the first problem by allowing a push notification to be delivered to a user or group of users. But:

  • it is no longer supported.
  • it doesn't work anymore (in my experience). IOs notifications appear, but they do not vibrate on the phone or do not sound. Some people suggested hacks to get around it, but none of them work for me.
  • it asks for a version of your production passwords and .pem files, which, of course, are not considered safe for a proper 12-factor application.

Pushwoosh is a service that simplifies sending push notifications to your application and includes automatic configuration and processing of your .pem files and certificates and a super-rich feature set.

lpender:meteor-pushwoosh is a package I wrote that

  • Allows your application to create and receive push notifications.
  • Allows you to prompt the user when creating a notification.
  • Works for iOS and Android devices.

Keep in mind that this is not fully visible on the pricing page, but after the free trial it is $ 49 per month to continue using their API to programmatically generate messages from your application.

+3
source share

If you only care about iOS notifications, the apn package mentioned by alanning can do the job.

However, Meteor has a raix: push package, which is much easier to use and supports notifications on APN iOS, Android GCM and partially on several other systems (APN Safari website, GCM Chrome OS, Firefox OS).

+2
source share

All Articles