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

What is the correct way to send VoIP Push using Node (Firebase Cloud Function) #25

Open
SirJAKfromSpace opened this issue Dec 3, 2020 · 2 comments
Labels
question Further information is requested

Comments

@SirJAKfromSpace
Copy link

i'm using the @parse/node-apn npm package in my firebase cloud function to request for a push.

i seem to be getting 'notifs sent: 0 failed: 1' when printing results.sent and results.failed.
i'm pretty sure that the VoIP Token being used is the one produced by the voip_kit instance (i checked logs).
please can someone confirm whether I'm calling the APNs properly? any idea where the problem could be?

const options = {
    token: {                                    //  hidden for privacy
        key: __dirname + "/../AuthKey_SECRET_KEYID.p8",
        keyId: "SECRET_KEYID",
        teamId: "SECRET_TEAMID",
    },
    production: true,
};
const apnProvider = new apn.Provider(options);

export const apncallpush = functions.https.onRequest(async (req, res) => {
    const callerid = req.body.callerid;
    const callername = req.body.callername;
    const callertoken = req.body.calleetoken;

    const note = new apn.Notification();
    const deviceToken = `${callertoken}`
    note.payload = {
        "aps": {
            "alert": {
                "uuid": `f579cc8c-7127-4ca3-a9f5-dd4a591a2567`,
                "incoming_caller_id": `${callerid}`,
                "incoming_caller_name": `${callername}`,
            },
        },
    };
    note.contentAvailable = true;
    note.expiry = Math.floor(Date.now() / 1000) + 60;
    note.priority = 10;
    note.pushType = "voip";
    note.topic = "BUNDLE_ID.voip";    //  hidden for privacy

    apnProvider.send(note, deviceToken).then((result) => {
        const r = `DONE! notifs sent: ${result.sent.length} failed: ${result.failed.length}`;
        console.log(r);
    }).catch(() => {
        console.log('NOPE notif not sent');
    });

and i only have 1 iOS device not 2, so sadly i cant try out the example app.
i also tried the CURL command mentioned in the doc. it connects to api.sandbox.apple and my .pem certificate verifies OK.
finally it outputs:

* Connection state changed (MAX_CONCURRENT_STREAMS == 1000)!
* We are completely uploaded and fine
< HTTP/2 200 
< apns-id: A2ED1505-EE9D-CD19-955B-84669C7322A2
< 
* Connection #0 to host api.sandbox.push.apple.com left intact
* Closing connection 0
@masashi-sutou
Copy link
Owner

masashi-sutou commented Dec 10, 2020

@SirJAKfromSpace

  • Is the APNs endpoint and certificate of Sandbox correct?

Development server: api.sandbox.push.apple.com:443
Production server: api.push.apple.com:443
https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns/

@masashi-sutou masashi-sutou added the question Further information is requested label Dec 10, 2020
@mars3142
Copy link

mars3142 commented Mar 11, 2021

I do have the same problem. The curl returns 200 and my app doesn't response to it.

Edit: After compiling in release mode, the push did open the calling ui.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants