raix-push icon indicating copy to clipboard operation
raix-push copied to clipboard

Anyone got this working with the new Apple p8 files

Open adamgins opened this issue 7 years ago • 15 comments

Hi, the current params are dependent on the old p12 based certs, Apple does to issue those any more. Wondering if anyone else has got this working with the new p8 files?

adamgins avatar Dec 28 '17 04:12 adamgins

@adamgins I think we might have to bump the apn module version - there are a couple of breaking api changes around v2.0.0 https://github.com/node-apn/node-apn/releases

raix avatar Dec 28 '17 05:12 raix

@raix yep just looking at https://github.com/node-apn/node-apn it takes a whole bunch of the new params... eg

var options = {
  token: {
    key: "path/to/APNsAuthKey_XXXXXXXXXX.p8",
    keyId: "key-id",
    teamId: "developer-team-id"
  },
  production: false
};

I will take a crack at it and see if I can fix. I am hoping it may be simple to get APN up and running again...

adamgins avatar Dec 28 '17 05:12 adamgins

BTW, there is another thought of using something like Firebase (FCM), which can now send to both APN and FCM/GCM... but that probably more of a fork??? ala https://github.com/fechanique/cordova-plugin-fcm

adamgins avatar Dec 28 '17 05:12 adamgins

https://github.com/raix/push/tree/chore/upgrade-apn-v2

raix avatar Dec 28 '17 06:12 raix

@adamgins I've added a branch with the initial stab - please crack on (I'm out today and tomorrow - my birthday)

re FCM I think it would be a really nice thing to get in, (GCM is deprecating in favor of FCM right?)

raix avatar Dec 28 '17 06:12 raix

@raix you're "da man!!!" happy birthday :-) and Happy New Year!!!

re: FCM yes... when I logged into FCM all my GCM stuff was there

adamgins avatar Dec 28 '17 06:12 adamgins

@raix I cloned and just put into my packages to see if I could get working and hack as necessary

I changed apn.Device to apn.Provider in var myDevice = new apn.Provider(userToken); at https://github.com/raix/push/blob/master/lib/server/push.api.js#L187

I am getting this error Push: Could not send notification id: "ab4ikEykgKAk83RyZ", Error: ENOENT: no such file or directory, open 'cert.pem'

Seems related to this deep in the included NPM modules https://github.com/node-apn/node-apn/blob/master/test/config.js#L22

I was a bit confused that we still needed to include

cert: Assets.getText(some_cert.pem'),
        key: Assets.getText('some_key.pem'),

I thought these were redundant with the new settings, anyway

My config is

Push.Configure({
		apn: {
			token: {
				key: Assets.getText('APN_PUSH.p8'),
				keyId: '<mykey>',
				teamId: '<myteamid>',
			},

			// passphrase: 'amonkey-surfer',
			//production: false,
			//gateway: 'gateway.push.apple.com',

		},
		gcm: {
			apiKey: '<gcmkey>',
		},
		cert: Assets.getText('<my>_cert.pem'),
		key: Assets.getText('<my>_key.pem'),
		production: false,
		'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,
		//
	});

I ended up at https://github.com/node-apn/node-apn/blob/master/doc/provider.markdown and it still seems like cert and key are required, phew in to the APN gorp of creating keys and certs again :-/ This seems even more complex than before... been a long day, trying to get my head around this.

adamgins avatar Dec 28 '17 10:12 adamgins

@adamgins did you mean to say that Apple doesn't issue p12 any more? I am not able to find any info on that. What I see however is that FCM requires p8 which is easily converted from p12. Were there any announcement of discontinuation of p12 certificates?

paulincai avatar Jan 18 '18 16:01 paulincai

can anybody confirm if p12 is obsolete? I haven't found anything about it anywhere like @paulincai mentioned. As that might be something causes my problems to send push notifications thru APN.

twentyfortysix avatar Oct 14 '18 12:10 twentyfortysix

@twentyfortysix is this a project that worked fine and stopped working or is it something that you're developing now and can't send out via APN?

paulincai avatar Oct 14 '18 14:10 paulincai

New project that I have never been able to setup for APN. I made a small demo, with the description.. #350

twentyfortysix avatar Oct 14 '18 15:10 twentyfortysix

As fr as I remember, you need to "distribute" your app. Can you do a ad-hoc distribution and put it in testfairy or other place and try again. For some reasons I know that you can only receive in IOS with a production app.

paulincai avatar Oct 14 '18 16:10 paulincai

Thanks for help. I tried it via TestFlight. no luck so far.

twentyfortysix avatar Oct 14 '18 16:10 twentyfortysix

I have some time for you if you want to go on a chat: paulailincai in skype

paulincai avatar Oct 14 '18 16:10 paulincai

I have some time for you if you want to go on a chat: paulailincai in skype mine is o----o. I have sent you request a minute ago

twentyfortysix avatar Oct 14 '18 16:10 twentyfortysix