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

iOS 13 - Notfications not received when app closed #18

Open
nocodedweb opened this issue May 9, 2020 · 7 comments
Open

iOS 13 - Notfications not received when app closed #18

nocodedweb opened this issue May 9, 2020 · 7 comments

Comments

@nocodedweb
Copy link

Hello there! Trying to display an incoming call using this plugin with no luck so far. I installed this plugin yesterday and was able to receive a test VoIP notification alert using an AWS SNS application endpoint once, then I didn't receive any alerts after when the app was completely closed or minimized. However, I would receive alerts with the "notification" event if the app was open and visible. Did I miss something in the implementation?

I'm on iOS 13.4, compiling in Xcode 11. Thanks in advance!

@wmehanna
Copy link

@nocodedweb any luck with that so far ? I'm also struggling with that.

@AleksandarTokarev
Copy link

AleksandarTokarev commented Sep 8, 2020

@nocodedweb Did you managed to get this working?
I am seeing the same issue. test VOIP with simplepush.php script works when app is open, but it does not when app is in background/closed

@danielehrhardt
Copy link

Did someone was able to make it work?

@AleksandarTokarev
Copy link

AleksandarTokarev commented Dec 30, 2020

@danielehrhardt
We managed to get it working, here is a working version of the plugin that we are using
https://github.com/AleksandarTokarev/cordova-plugin-callkit/tree/trusted-care-master
Make sure you are on branch trusted-care-master, as in the link
We are using AWS SNS to send VoiP Push Notifications with NodeJs, here is the code for that:

const caller = `${currentUser.profile.firstname} ${currentUser.profile.lastname}`
        let voip_protocol = `APNS_VOIP` // `APNS_VOIP_SANDBOX` for Sandbox AWS Env
        let payload = {}
        let voip_protocol_value = `{"aps" : { "alert": "New Incoming Call" }, "data" : { "Caller": { "Username" : "${caller}", "ConnectionId": "${callId}", "CallbackUrl": "${getExternalRootUrl()}updateStatus", "CancelPush": "${isCancel}"}}}`
        payload[`${voip_protocol}`] = voip_protocol_value
        let params = {
            'Message': JSON.stringify(payload),
            'MessageAttributes': {
                'AWS.SNS.MOBILE.APNS.PRIORITY': {
                    'DataType': 'String',
                    'StringValue': '10',
                },
                'AWS.SNS.MOBILE.APNS.PUSH_TYPE': {
                    'DataType': 'String',
                    'StringValue': 'voip',
                },
                [`AWS.SNS.MOBILE.${voip_protocol}.TTL`]: {
                    'DataType': 'String',
                    'StringValue': '0',
                },
            },
            'MessageStructure': 'json',
            'TargetArn': userWithTokenFound.endpointArn,
        }

        try {
            sns.publish(params).promise()
            Logger.info(`IOS Voip Push for user sent`, { user_id })
        } catch (error) {
            Logger.info(`IOS Voip Push for user sending error`, { error })
        }

Basically here is the logic,
We maintain a list of statuses of the call in the database, connecting, ringing, active, ended.
We use the getExternalRootUrl() method to get the URL of the server that the 'Mobile Device' calls an endpoint on to change the status.
Let me know if u have any questions

@danielehrhardt
Copy link

@danielehrhardt
We managed to get it working, here is a working version of the plugin that we are using
https://github.com/AleksandarTokarev/cordova-plugin-callkit/tree/trusted-care-master
Make sure you are on branch trusted-care-master, as in the link
We are using AWS SNS to send VoiP Push Notifications with NodeJs, here is the code for that:

const caller = `${currentUser.profile.firstname} ${currentUser.profile.lastname}`
        let voip_protocol = `APNS_VOIP` // `APNS_VOIP_SANDBOX` for Sandbox AWS Env
        let payload = {}
        let voip_protocol_value = `{"aps" : { "alert": "New Incoming Call" }, "data" : { "Caller": { "Username" : "${caller}", "ConnectionId": "${callId}", "CallbackUrl": "${getExternalRootUrl()}updateStatus", "CancelPush": "${isCancel}"}}}`
        payload[`${voip_protocol}`] = voip_protocol_value
        let params = {
            'Message': JSON.stringify(payload),
            'MessageAttributes': {
                'AWS.SNS.MOBILE.APNS.PRIORITY': {
                    'DataType': 'String',
                    'StringValue': '10',
                },
                'AWS.SNS.MOBILE.APNS.PUSH_TYPE': {
                    'DataType': 'String',
                    'StringValue': 'voip',
                },
                [`AWS.SNS.MOBILE.${voip_protocol}.TTL`]: {
                    'DataType': 'String',
                    'StringValue': '0',
                },
            },
            'MessageStructure': 'json',
            'TargetArn': userWithTokenFound.endpointArn,
        }

        try {
            sns.publish(params).promise()
            Logger.info(`IOS Voip Push for user sent`, { user_id })
        } catch (error) {
            Logger.info(`IOS Voip Push for user sending error`, { error })
        }

Basically here is the logic,
We maintain a list of statuses of the call in the database, connecting, ringing, active, ended.
We use the getExternalRootUrl() method to get the URL of the server that the 'Mobile Device' calls an endpoint on to change the status.
Let me know if u have any questions

Thank you so much!!

@danielehrhardt
Copy link

@AleksandarTokarev
Copy link

AleksandarTokarev commented Dec 30, 2020

@danielehrhardt for Android Push Notifications and calling we are using my fork and this branch https://github.com/AleksandarTokarev/phonegap-plugin-push/tree/android-native-caller . We modified it to work with Android 10
The link on my previous comment is only for IOS

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

4 participants