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

Creating Device Object #39

Closed
baboya opened this issue May 18, 2012 · 6 comments
Closed

Creating Device Object #39

baboya opened this issue May 18, 2012 · 6 comments

Comments

@baboya
Copy link

baboya commented May 18, 2012

Hi,

I have a token as below and I'm trying to create a Device object
"d5c1e588 9d336101 fb74bdea ae64b61e 037cc958 f27d50dd ed9c91da 9d6c5e53"

var myDevice = new apns.Device("c1d5e5889d336101fb74bdeaae64b61e037cc958f27d50dded9c91da9d6c5e53d78", ascii=false);
var note = new apns.Notification();

note.badge = 3;
note.alert = "You have a new message";
note.device = myDevice;
apnsConnection.sendNotification(note);

And I keep getting:
TypeError: Object c1d5e5889d336101fb74bdeaae64b61e037cc958f27d50dded9c91da9d6c5e53d78 has no method 'copy'

Thanks,

@argon
Copy link
Collaborator

argon commented May 18, 2012

Try getting rid of "ascii=false"

@baboya
Copy link
Author

baboya commented May 18, 2012

So I console.log both token and message and this is what I get...

Does this look right?

Thanks,

������� : {"aps":{"badge":3,"alert":"You have a new message"}}

@argon
Copy link
Collaborator

argon commented May 19, 2012

Most likely. What happens when you send it now? Do you have an error handling callback set?

@baboya
Copy link
Author

baboya commented May 19, 2012

I'm passing a callback like this:

var options = {
    cert: 'apns-dev-cert.pem',                 /* Certificate file */
    certData: null,                   /* Optional: if supplied uses this instead of Certificate File */
    key:  'apns-dev-key.pem',                  /* Key file */
    keyData: null,                    /* Optional: if supplied uses this instead of Key file */
    passphrase: 'test',                 /* Optional: A passphrase for the Key file */
    gateway: 'gateway.push.apple.com',/* gateway address */
    port: 2195,                       /* gateway port */
    enhanced: true,                   /* enable enhanced format */
    errorCallback: errorCallback,         /* Callback when error occurs */
    cacheLength: 5                    /* Number of notifications to cache for error purposes */
};

var errorCallback = function (err, n) {
console.log('Error : ' + err + ' : ' + n);
}

and nothing is coming back... no error and no push notification sent to my device.

Not exactly sure what's going on I found a simple php and using the same device id and certs it worked fine...

Thanks,

@baboya
Copy link
Author

baboya commented May 19, 2012

I just read on another issue and found out I had the same issue...

I needed to send it to : gateway.sandbox.push.apple.com
instead of gateway.push.apple.com

Can you write some a description about this?

if you have dev push notification cert use : gateway.sandbox.push.apple.com

Thank you so much for creating this library.

@argon
Copy link
Collaborator

argon commented May 22, 2012

Refer to issue #40

@argon argon closed this as completed May 22, 2012
hharanm pushed a commit to hharanm/node-apn that referenced this issue Apr 16, 2023
* Add GitHub actions

* Add github token to coveralls

* Add github token

* Add COVERALLS_REPO_TOKEN
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