ios - swift 3 push notifications on parse -
i using bitnami parse server on aws run social media app. having trouble push notifications.
i arranged certificate, domain id, push notification enable options etc.
i foun code below on eladnava. worked on js , 1 has manually run code send manual push notification.
however want execute push notification system within app automate notification process. like, if gets message inside of app, have push notification.
do have idea how can that? bear in mind i'm using parse.
var apn = require('apn'); // set apn apns auth key var apnprovider = new apn.provider({ token: { key: '', // path key p8 file keyid: '', // key id of p8 file teamid: '', // team id of apple developer account (available @ https://developer.apple.com/account/#/membership/) }, production: false // set true if sending notification production ios app }); // enter device token xcode console var devicetoken = ''; // prepare new notification var notification = new apn.notification(); // specify ios app's bundle id (accessible within project editor) notification.topic = ''; // set expiration 1 hour (in case device offline) notification.expiry = math.floor(date.now() / 1000) + 3600; // set app badge indicator notification.badge = 3; // play ping.aiff sound when notification received notification.sound = 'ping.aiff'; // display following message (the actual notification text, supports emoji) notification.alert = 'notification message \u270c'; // send payload data notification accessible app in didreceiveremotenotification notification.payload = {id: 123}; // send notification apnprovider.send(notification, devicetoken).then(function(result) { // check result failed devices console.log(result); });
Comments
Post a Comment