Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Naveen Singh
    @w0w
    Option [__dataSource] set to null. This may cause unexpected behaviour.
    what does this mean, using DEBUG=apn node app.js to debug and cannot make sense of it
    Andrew Naylor
    @argon
    It looks like you're passing an object to the constructor which was loaded from some kind of data store, is that correct? In this case it is a harmless warning as the property name __dataSource
    Does not conflict with any of the configuration property names.
    Naveen Singh
    @w0w
    @argon yup i am using loopback which has dataSource object
    so it must be that
    Andrew Naylor
    @argon
    Ok, in that case the warning is harmless
    Naveen Singh
    @w0w
    @argon I was wondering how much performance difference will it make when i use
              var options = {
                  cert:  apnsCert,
                  certData: null,
                  key:apnsKey,
                  keyData: null,
                  passphrase: 'asdfgh',
                  ca: null,
                  gateway: 'gateway.sandbox.push.apple.com',
                  port: 2195,
                  enhanced: true,
                  errorCallback: function(err,notifcation){
                    console.log(err);
                    console.log(notifcation);
                  },
                  cacheLength: 100
              };
    when i use cert and key options
    instead of certData and keyData
    Naveen Singh
    @w0w
    does it perform fileread operation everytime a notification is sent
    Andrew Naylor
    @argon
    It will perform a file read operation each time a Connection object is created by you. Which should be once.
    Naveen Singh
    @w0w
          else if (item.deviceType==='ios') {
            // Use apn to send notification
            Push.app.models.application.findById(item.appId, function(err, a){
              if(err) { return cb(err);}
              var apnsCert = path.join(__dirname + '/../../server/credentials/', 'apns_cert_dev.pem');
              var apnsKey = path.join(__dirname + '/../../server/credentials/', 'apns_key_dev.pem');
              var options = {
                  cert:  apnsCert,
                  certData: null,
                  key:apnsKey,
                  keyData: null,
                  passphrase: 'asdfgh',
                  ca: null,
                  gateway: 'gateway.sandbox.push.apple.com',
                  port: 2195,
                  enhanced: true,
                  errorCallback: function(err,notifcation){
                    console.log(err);
                    console.log(notifcation);
                  },
                  cacheLength: 100
              };
              var apnsConnection = new apns.Connection(options);
              var token = item.deviceToken;
              var myDevice = new apns.Device(token);
              var note = new apns.Notification();
    
              note.expiry = Math.floor(Date.now() / 1000) + 3600; // Expires 1 hour from now.
              note.badge = 1;
              note.sound = "ping.aiff";
              note.alert = ""+ ctx.text;
              note.payload = ctx;
              note.device = myDevice;
              apnsConnection.sendNotification(note);
              cb();
            });
          }
    Andrew Naylor
    @argon
    You're creating a new connection every time you send a notification. You're going to see terrible performance as each connection can take up to a second to create.

    From Apples Docs:

    Keep your connections with APNs open across multiple notifications; don’t repeatedly open and close connections. APNs treats rapid connection and disconnection as a denial-of-service attack. You should leave a connection open unless you know it will be idle for an extended period of time—for example, if you only send notifications to your users once a day it is ok to use a new connection each day.

    Naveen Singh
    @w0w
    please if possible guide me how to create a connection just once
    Andrew Naylor
    @argon
    Don't create more than one apns.Connection object. Create it once elsewhere and reuse it whenever you need to send a push notification
    Sean Thornton
    @s-thornton
    @argon Hey, great module, I just have a quick question. my apn connection keeps connecting and disconnecting when I attempt to send out push notifications
    Screen Shot 2016-06-08 at 3.55.08 PM.png
    Debjeet Sarkar
    @debjeet-sarkar
    @s-thornton ,hey even I faced the same issue, This is how the protocol works
    So everytime you make a failed attempt to send a PN it ends the existing connection. It is then the lib’s responsibility to reconnect again as a continuity plan
    So its fine :)
    Weslei Prudencio
    @wprudencio
    I usually use this(https://gist.github.com/slangley/4490928) php script to send notifications, I need just the ck.pem and passphrase. Why I need keyId and teamId to send notifications on node-apn?
    Debjeet Sarkar
    @debjeet-sarkar
    Hey @wprudencio , A combined cert can be made using both the cert & key and can be used . Something along this lines : http://stackoverflow.com/questions/11536587/creating-pem-file-for-push-notification
    Muhammad Bilal
    @beelaal
    i want to send push notification through my website how i can setup this plugin for my website??
    _
    i am using push.js https://github.com/Nickersoft/push.js