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

Anyone got this working with the new Apple p8 files #326

Open adamgins opened 6 years ago

adamgins commented 6 years ago

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?

raix commented 6 years ago

@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

adamgins commented 6 years ago

@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 commented 6 years ago

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

raix commented 6 years ago

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

raix commented 6 years ago

@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?)

adamgins commented 6 years ago

@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 commented 6 years ago

@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.

paulincai commented 6 years ago

@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?

twentyfortysix commented 5 years ago

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.

paulincai commented 5 years ago

@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?

twentyfortysix commented 5 years ago

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

paulincai commented 5 years ago

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.

twentyfortysix commented 5 years ago

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

paulincai commented 5 years ago

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

twentyfortysix commented 5 years ago

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