Meteor-Community-Packages / raix-push

DEPRECATED: Push notifications for cordova (ios, android) browser (Chrome, Safari, Firefox)
https://atmospherejs.com/raix/push
MIT License
514 stars 197 forks source link

Got error code 8 for token [...] #145

Closed lucnat closed 8 years ago

lucnat commented 8 years ago

I am in the process of deploying my app to the app store. I have tested all certicates and keys (development and production) and they are fine. Push works perfectly in development. However, when I set NODE_ENV to production and also "production": true in config.push.json, it won't work anymore. Upon sending a push notification, I get the following error:

[46.101.207.204] Push: Sent message "Laptop" to 1 ios apps 0 android apps[46.101.207.204] 
[46.101.207.204] Got error code 8 for token e4f493fa53f80ecceb8351c878b028caa91bd050d1c075a9f385deb4b24a9750[46.101.207.204] 

I can imagine that this happens because the app has been installed via xcode on the device. Can anybody confirm? Will the message disappear once the app has been installed through the app store? And what is the correct push setting to use with Apple TestFlight?

Streemo commented 8 years ago

Did you ever find a fix for this? I am also running my code in production just as you are.

I think you have to specify which mode you're using in the developer console for apple?

https://github.com/argon/node-apn/issues/135

I am also having this issue. I think it's worth noting that the following worked for both my production and my development .pem files.

$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 
  -cert PushChatCert.pem -key PushChatKey.pem
Enter pass phrase for PushChatKey.pem: 

Given that this worked, I am not quite sure why I'm getting:

[123.456.789.012] Push: Sent message "request accepted!" to 1 ios apps and 0 android apps
[123.456.789.012] Got error code 8 for token sakjdgfhasjkdfhasdjkfhsdfhiufhsdjkfahsdjkfhsdjfjasdhfkajasdkjfh=
Streemo commented 8 years ago

@LucNaterop I'm actually also having this issue in development.

That's strange. You said it was working fine in development? What did your config and env look like?

Thanks

Streemo commented 8 years ago

Got this working -- XCode's provisioning profiles and certificates is one giant spaghetti dinner. Still no luck on the production settings, though :(

lucnat commented 8 years ago

@Streemo Production certificates will not work if the app was installed via XCode. Thus, if you installed your app via XCode on your device and use production settings, you will get error code 8 (given your certificates are fine). So how can we test production settings before submitting the app to the store? Via Testflight (Apples platform for beta testing). If you install your app via Testflight (you need to upload an archive to itunesconnect for that and configure Testflight) then it will work with production certificates. Good luck!

Streemo commented 8 years ago

@LucNaterop I see, yeah I was going to try an ad-hoc build or testflight. Thanks! When it comes to xcode, I'm gonna need all the luck I can get...

Streemo commented 8 years ago

@LucNaterop your suggestion worked :) If using production set to true, we need to build the meteor app, archive the resultant xcode project with the appropriate code signing and provisioning profile keys (etc.), validate it, submit it to the app store, and then use iTunes Connect to modify the meta-data, create testflight users, and start a testflight build. Doing all of the above allowed me to use push notifications (APN) as expected. Thanks for your help!!

da314pc commented 4 years ago

@phamduc0810 For IOS you can only test push notifications once the build is uploaded to itunes connect. Upload app with Xcode and install with test flight..

da314pc commented 4 years ago

@phamduc0810 That is an error trying to test push notifications in a dev environment

lokiribeiro commented 4 years ago

I really need help. Everything else seems to be working except push notifications for IOS. been stuck at this for months now. I'm certain that im using the right certificates and keys but I still get error code 8

da314pc commented 4 years ago

@lokiribeiro how are you testing ios?

lokiribeiro commented 4 years ago

I tried testing in xcode dev with development certificates and also in testflight with production certificates, signing profiles and environment set to production. Both gives error code 8

da314pc commented 4 years ago

To test ios, you have to build, then do in flight testing.. (iTunes connect). Dev certs should work. but unless you download the app through the in-flight testing, it wont work on ios .

lokiribeiro commented 4 years ago

So I should be able to receive push notifications with dev cert as long as Xcode installs it on the test device right? and not from test flight.

da314pc commented 4 years ago

No, I mean no certs will work unless the app is installed from the store. Inflight testing also installs from the store Did you try https://github.com/raix/push/wiki/raix:push-Newbie-Manual If so your certs are probably correct.

lokiribeiro commented 4 years ago

Alright, thanks. I'll try this out

da314pc commented 4 years ago

Have you upload the ios build to the store?

lokiribeiro commented 4 years ago

yes. it's both in testflight and in official app store now. Sidenote: no need to include gateway: 'gateway.push.apple.com' ?

lokiribeiro commented 4 years ago

I got this for both certs: SSL-Session: Protocol : TLSv1.2 Cipher : DES-CBC3-SHA Session-ID: Session-ID-ctx: Master-Key: 265A2E3675EAEB3D2B5B9A65F39B6202A7314411B2099A698BB5E24E276E83ED1D9E288ECC37D5A1B63538DC21C5CCBB Start Time: 1580876489 Timeout : 7200 (sec) Verify return code: 0 (ok)

da314pc commented 4 years ago

Good your certs appear good. In Xcode, just put the device on generic ios device, Xcode -> Product -> Archive or use the transporter then on Itunes connect, click the app, then TestFlight section. https://reinteractive.com/posts/344-how-to-upload-your-ios-app-to-testflight-for-distribution-beta

lokiribeiro commented 4 years ago

Here's my signing & capabilities settings: Screen Shot 2020-02-05 at 12 48 53 PM

Here's my profile before uploading to appstore: Screen Shot 2020-02-05 at 12 57 03 PM

lokiribeiro commented 4 years ago

and here's my config: Push.Configure({ // Google Cloud Messaging apn: { certData: Assets.getText('cert.pem'), keyData: Assets.getText('key.pem'), passphrase: '*', gateway: 'gateway.push.apple.com' }, gcm: { projectNumber: ***, apiKey:"" }, production: true });

lokiribeiro commented 4 years ago

and here's how I deploy my app to production in server: sudo MONGO_URL=mongodb://* ROOT_URL=http://*** PORT= NODE_ENV=production METEOR_SETTINGS='{"AWSAccessKeyId" : "**","AWSSecretAccessKey" : "**","SENDGRID_API_KEY" : ""}' pm2 start main.js --name main

da314pc commented 4 years ago

looks fine. just upload it to the store. Once uploaded, inside itunes connect just use the testflight section and submit the build. You will need to add testers.

lokiribeiro commented 4 years ago

I did everything and still get this error: Push: Send message "Engineer on watch" via query { userId: 'kL2QqFdDTHfQsQbTH' } send to token { apn: 'cYgRvgvJrl0:APA91bHAk2s8q3e9o5Aemh02Bv2KsUVSX3Ipe36pGSwz3dfQOq-K4nXtbJs9Qp4dRVe1kwP83ngCLQUZAnnJ0fzsIl3sfIpwesQHJwh6Z8gYBDU2yFpvESsRmHoXY75ytcHjCzpmsZ0_' } Push: Sent message "Engineer on watch" to 1 ios apps 0 android apps Push, GUIDE: The "Push.appCollection" - No GCM clients have registred on the server yet... Got error code 8 for token cYgRvgvJrl0:APA91bHAk2s8q3e9o5Aemh02Bv2KsUVSX3Ipe36pGSwz3dfQOq-K4nXtbJs9Qp4dRVe1kwP83ngCLQUZAnnJ0fzsIl3sfIpwesQHJwh6Z8gYBDU2yFpvESsRmHoXY75ytcHjCzpmsZ0

At this point I really don't know what seem to be wrong.

lokiribeiro commented 4 years ago

This was the log from the server after trying to send a push notification to my testflight app.

da314pc commented 4 years ago

so you installed the app from the store?

lokiribeiro commented 4 years ago

from the testflight app, I added myself as a tester

lokiribeiro commented 4 years ago

I've exhausted every option. I'm thinking if there's any luck by using p8 files instead?

lokiribeiro commented 4 years ago

I receive notifications when I fire them from Firebase console cloud messaging using the p8 file I got from Apple Developer Site

da314pc commented 4 years ago

are you using the production mode?

da314pc commented 4 years ago

yes try p8 files

lokiribeiro commented 4 years ago

how do I know if im using production mode?

lokiribeiro commented 4 years ago

also is there any documentation for using p8 files? I can't seem to find it in the readMe file here. Thank you

da314pc commented 4 years ago

on server: Push.Configure({ apn: { certData: Assets.getText('apnDevCert.pem'), keyData: Assets.getText('apnDevKey.pem'), passphrase: 'xxxxxxxxx', production: true, //gateway: 'gateway.push.apple.com', }, gcm: { apiKey: 'xxxxxxx', // GCM/FCM server key } // production: true, // 'sound' true, // 'badge' true, // 'alert' true, // 'vibrate' true, // 'sendInterval': 15000, Configurable interval between sending // 'sendBatchSize': 1, Configurable number of notifications to send per batch // 'keepNotifications': false, // });

da314pc commented 4 years ago

try to the production certs

lokiribeiro commented 4 years ago

Is there any documentation too about using p8 files in raix:push?

da314pc commented 4 years ago

Delete your collections in the apptokens database. then open the ios app to see if the token registers we want to make sure your not using an old token when the device wasn't installed with testflight.

lokiribeiro commented 4 years ago

Yup, I did that too earlier. I deleted all the app tokens and opened my app. The tokens do register.

da314pc commented 4 years ago

oh, so the new token from the testflight app is not registering?

lokiribeiro commented 4 years ago

They register correctly in the apptokens database

da314pc commented 4 years ago

so before you installed the testflight app you cleared the collection correct?

lokiribeiro commented 4 years ago

yes correct.

da314pc commented 4 years ago

so how did you install the app?

lokiribeiro commented 4 years ago

I redeemed it from the testflight app installed on the device.

lokiribeiro commented 4 years ago

I just noticed that my Push.Configure block is inside the client/api folder. Maybe that's causing the error? I transferred it to server side now and rebuild.

da314pc commented 4 years ago

no you need the push on both client and server client: Push.Configure({ android: { senderID: 12341234, alert: true, badge: true, sound: true, vibrate: true, clearNotifications: true // icon: '', // iconColor: '' }, ios: { alert: true, badge: true, sound: true } });

server: Push.Configure({ apn: { certData: Assets.getText('apnDevCert.pem'), keyData: Assets.getText('apnDevKey.pem'), passphrase: 'xxxxxxxxx', production: true, //gateway: 'gateway.push.apple.com', }, gcm: { apiKey: 'xxxxxxx', // GCM/FCM server key } // production: true, // 'sound' true, // 'badge' true, // 'alert' true, // 'vibrate' true, // 'sendInterval': 15000, Configurable interval between sending // 'sendBatchSize': 1, Configurable number of notifications to send per batch // 'keepNotifications': false, // });

da314pc commented 4 years ago

so your server end has the credentials & certs the client just makes sure the token registers correctly

lokiribeiro commented 4 years ago

I got both client and server blocks on my mainstartup.js file earlier. Now I transferred the latter to my server side scripts.

It's weird cause it worked with notifications for android even though both are in mainstartus.js

da314pc commented 4 years ago

Did it work?

lokiribeiro commented 4 years ago

I'll let you know. I'm rebuilding it atm and will deploy the new build to the production server