Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari (Desktop) Push Notifications #159

Closed
emadd opened this issue Apr 1, 2014 · 15 comments
Closed

Safari (Desktop) Push Notifications #159

emadd opened this issue Apr 1, 2014 · 15 comments

Comments

@emadd
Copy link

emadd commented Apr 1, 2014

I'm a veteran of push notifications for iOS, but this is my first Safari experience. I'm fairly certain I'm doing things correctly but I'm not getting any notifications. Here's my debug output...

//LOG OF NOTE
{ encoding: 'utf8',
  payload: {},
  expiry: 1396425645,
  identifier: 0,
  priority: 10,
  retryLimit: -1,
  device: undefined,
  alert: 'Test notification',
  badge: 1,
  sound: undefined,
  newsstandAvailable: undefined,
  contentAvailable: undefined,
  mdm: undefined,
  compiled: false,
  truncateAtWordEnd: false
}

//LOG OF DEVICE
{ token: <Buffer 48 69 54 db 1f 96 68 d1 aa 4e c1 b6 05 fc 0b a1 76 6e 69 96 37 4a 0f 43 68 6d 7b ef 83 fe b8 7d> }

//DEBUG OUTPUT
  apn Initialising connection +0ms
  apn Initialising module +1ms
  apn 1 left to send +1ms
  apn Connection established +642ms
  apn Transmitting notification from buffer +0ms
  apn Socket drained +1ms 0
  apn 0 left to send +0ms
  apn 0 left to send +0ms
@argon
Copy link
Collaborator

argon commented Apr 1, 2014

I'm afraid I haven't done anything with Safari Notifications yet. I did look over the docs when it was released and couldn't see any obvious problems that might occur. I will try to get a development environment setup soon to investigate this. In the mean-time, if you make any progress please keep this issue up to date.

@emadd
Copy link
Author

emadd commented Apr 1, 2014

notnoop/java-apns#135

Sent from my iPhone

On Apr 1, 2014, at 10:45 AM, Andrew Naylor notifications@github.com wrote:

I'm afraid I haven't done anything with Safari Notifications yet. I did look over the docs when it was released and couldn't see any obvious problems that might occur. I will try to get a development environment setup soon to investigate this. In the mean-time, if you make any progress please keep this issue up to date.


Reply to this email directly or view it on GitHub.

@argon
Copy link
Collaborator

argon commented Apr 1, 2014

38d2256

@argon
Copy link
Collaborator

argon commented Apr 1, 2014

My bad. I see the title and action options are missing. I will add them.

@emadd
Copy link
Author

emadd commented Apr 4, 2014

Any estimate on when we might see this implemented? Many thanks.

Edit: I'd contribute but I'm somewhat of a node newb.

@argon
Copy link
Collaborator

argon commented Apr 7, 2014

I'm just working on it at the moment. I won't be able to push it to npm for a little while as I have some other stuff I want to complete but it will be available on here.

@argon argon closed this as completed in 94a4990 Apr 7, 2014
@emadd
Copy link
Author

emadd commented Apr 7, 2014

Fantastic. I've just cloned this locally and I'm still not getting the push notifications. Anything wrong with this?

var options = {
    "gateway": config.apn.gateway
};
var apnConnection = new apn.Connection(options);
var device = new apn.Device(recipient.safaritokens[0]);
var pushNote = new apn.Notification();

pushNote.expiry = Math.floor(Date.now() / 1000) + 3600; // Expires 1 hour from now.
pushNote.badge = 1;
pushNote.alertTitle = nMessage;
pushNote.alertAction = 'View';
pushNote.alert = 'Click me';
pushNote.urlArgs = [];
pushNote.payload = {};

console.log('device: '+device);
console.log('pushNote: '+pushNote);

apnConnection.pushNotification(pushNote, device);

Debug output...

device: { token: <Buffer 48 69 54 db 1f 96 68 d1 aa 4e c1 b6 05 fc 0b a1 76 6e 69 96 37 4a 0f 43 68 6d 7b ef 83 fe b8 7d> }

pushNote: { encoding: 'utf8',
  payload: {},
  expiry: 1396915024,
  identifier: 0,
  priority: 10,
  retryLimit: -1,
  device: undefined,
  alert: 'Click me',
  badge: 1,
  sound: undefined,
  newsstandAvailable: undefined,
  contentAvailable: undefined,
  mdm: undefined,
  compiled: false,
  truncateAtWordEnd: false,
  urlArgs: [],
  alertTitle: 'My notification title',
  alertAction: 'View' }

  apn Initialising connection +0ms
  apn Initialising module +0ms
  apn 1 left to send +0ms
  apn Connection established +248ms
  apn Transmitting notification from buffer +0ms
  apn Socket drained +0ms 0
  apn 0 left to send +0ms
  apn 0 left to send +1ms

@emadd
Copy link
Author

emadd commented Apr 7, 2014

Ok. I dig around notification.js and discovered I needed to use setAlertTitle(). Also see this...

Notification.prototype.setAlertLabel = function(alertLabel) {
    this.prepareAlert();
    this.alert['action'] = alertTitle;
    return this;
}

Should it not be...

Notification.prototype.setAlertAction = function(alertAction) {
    this.prepareAlert();
    this.alert['action'] = alertAction;
    return this;
}

@argon
Copy link
Collaborator

argon commented Apr 8, 2014

I decided to change this as-per your suggestion. Will be documenting it all tonight.

-A

On 8 Apr 2014, at 00:26, emadd notifications@github.com wrote:

Ok. I dig around notification.js and discovered I needed to use setAlertTitle(). Also see this...

Notification.prototype.setAlertLabel = function(alertLabel) {
this.prepareAlert();
this.alert['action'] = alertTitle;
return this;
}
Should it not be...

Notification.prototype.setAlertAction = function(alertAction) {
this.prepareAlert();
this.alert['action'] = alertAction;
return this;
}

Reply to this email directly or view it on GitHub.

@emadd
Copy link
Author

emadd commented Apr 17, 2014

Any idea when this might be finalized? Much appreciate your work.

@argon
Copy link
Collaborator

argon commented Apr 17, 2014

I got side-tracked on some more pressing issues. I will do a 1.4.5 release to npm with some of the minor fixes over the weekend.

@argon
Copy link
Collaborator

argon commented Apr 19, 2014

v1.5.0 has been published to npm

-A

On 17 Apr 2014, at 06:33, emadd notifications@github.com wrote:

Any idea when this might be finalized? Much appreciate your work.


Reply to this email directly or view it on GitHub.

@emadd
Copy link
Author

emadd commented Apr 19, 2014

Excellent!

On Apr 19, 2014, at 3:27 AM, Andrew Naylor notifications@github.com wrote:

v1.5.0 has been published to npm

-A

On 17 Apr 2014, at 06:33, emadd notifications@github.com wrote:

Any idea when this might be finalized? Much appreciate your work.


Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHub.

@emadd
Copy link
Author

emadd commented Jun 11, 2014

Could you provide an example of a message specifically for Safari?

@argon
Copy link
Collaborator

argon commented Jul 24, 2014

The Apple docs can probably explain it far better than I can, as I haven’t done any work with Push Notifications on Safari: https://developer.apple.com/library/prerelease/mac/documentation/NetworkingInternet/Conceptual/NotificationProgrammingGuideForWebsites/PushNotifications/PushNotifications.html#//apple_ref/doc/uid/TP40013225-CH3-SW1

If you’re looking for just a payload example I would recommend looking at Listing 2-4

—A

On 11 Jun 2014, at 15:50, emadd notifications@github.com wrote:

Could you provide an example of a message specifically for Safari?


Reply to this email directly or view it on GitHub.

@gabrielairg gabrielairg mentioned this issue Aug 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants