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

on iOS, Callback function is not called when user click notification action where foreground: true #101

Closed
miteshsavani810 opened this issue Jun 23, 2021 · 0 comments · Fixed by #102

Comments

@miteshsavani810
Copy link

Bug Report

When user click action button Maybe then app comes to foreground but it doesn't call associate callback maybe_a function instead it calls "notification" callback function. If user click action button Accept then it calls associate callback accept_a function which is fine.

This issue is happening on iOS device only. on Android device, The associate callback function is getting called as expected.

Expected Behaviour

Action's callback should called when user click action on notification and app comes foreground.

Actual Behaviour

Instead of Action's callback app calls "notification" callback when app comes foreground.

Sample Push Data Payload

{
"to" : "device token",
"notification": {
"title": "Test Notification",
"body": "This offer expires at 11:30 or whatever",
"click_action": "invite"
},
"data": {
"notId": 12332
}
}

Sample Code that illustrates the problem

function configNew() {
const push = PushNotification.init({
ios: {
sound: true,
alert: true,
badge: true,
categories: {
invite: {
yes: {
callback: 'accept_a',
title: 'Accept',
foreground: false,
destructive: false
},
no: {
callback: 'reject_a',
title: 'Reject',
foreground: false,
destructive: false
},
maybe: {
callback: 'maybe_a',
title: 'Maybe',
foreground: true,
destructive: false
}
}
}
}
});

  push.on('accept_a', (data) => {
    // do something with the notification data

    console.log('acceped');

    push.finish(() => {
        console.log('accept callback finished');
    }, () => {
        console.log('accept callback failed');
    }, data.additionalData.notId);
});

push.on('reject_a', (data) => {
    // do something with the notification data

    console.log('reject called');
    push.finish(() => {
        console.log('reject callback finished');
    }, () => {
        console.log('reject callback failed');
    }, data.additionalData.notId);
});

push.on('maybe_a', (data) => {
    // do something with the notification data
    console.log('maybe called');

    push.finish(() => {
        console.log('maybe callback finished');
    }, () => {
        console.log('accept callback failed');
    }, data.additionalData.notId);
});
push.on('notification', data => {
    if(!data.additionalData.foreground) {
        alert('Notification called');
        alert(JSON.stringify(data));
        console.log(data);
    }
    
    push.finish(() => {
        console.log('notification callback finished');
    }, () => {
        console.log('notification callback failed');
    }, data.additionalData.notId);
});

push.on('registration', data => {
    console.log('device token');
    console.log(data);
});

}

Logs taken while reproducing problem

2021-06-23 14:51:40.667282+0530 Zimbra[8779:2069018] CDVWebViewEngine shouldReloadWebView::

2021-06-23 14:51:40.667579+0530 Zimbra[8779:2069018] CDVWebViewEngine shouldReloadWebView reload: 0
2021-06-23 14:51:40.669219+0530 Zimbra[8779:2069018] Push Plugin didReceiveNotificationResponse: actionIdentifier maybe_a, notification: {
aps = {
alert = {
body = "This offer expires at 11:30 or whatever";
title = "Test Notification 448484";
};
category = invite;
};
"gcm.message_id" = 1624440092415914;
"google.c.a.e" = 1;
"google.c.sender.id" = 23135529045;
notId = 12332;
}
2021-06-23 14:51:40.669431+0530 Zimbra[8779:2069018] Push Plugin userInfo {
actionCallback = "maybe_a";
aps = {
alert = {
body = "This offer expires at 11:30 or whatever";
title = "Test Notification 448484";
};
category = invite;
};
"gcm.message_id" = 1624440092415914;
"google.c.a.e" = 1;
"google.c.sender.id" = 23135529045;
notId = 12332;
}
2021-06-23 14:51:40.689015+0530 Zimbra[8779:2069018] coldstart
2021-06-23 14:51:40.689714+0530 Zimbra[8779:2069018] Warning: UNUserNotificationCenter delegate received call to -userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: but the completion handler was never called.
2021-06-23 14:51:40.888974+0530 Zimbra[8779:2069018] active
2021-06-23 14:51:40.889089+0530 Zimbra[8779:2069018] PushPlugin skip clear badge
2021-06-23 14:51:40.892172+0530 Zimbra[8779:2069018] Notification received
2021-06-23 14:51:40.892788+0530 Zimbra[8779:2069018] Push Plugin key: alert
2021-06-23 14:51:40.892846+0530 Zimbra[8779:2069018] Push Plugin key: category
2021-06-23 14:51:40.907830+0530 Zimbra[8779:2069018] Push Plugin register success: {length = 32, bytes = 0x8bcf3cf5 b35673f0 feb89922 56dff4e7 ... b5b40621 f886413f }
2021-06-23 14:51:52.754927+0530 Zimbra[8779:2069018] {"message":"This offer expires at 11:30 or whatever","title":"Test Notification 448484","additionalData":{"category":"invite","google.c.sender.id":"23135529045","google.c.a.e":"1","coldstart":true,"notId":"12332","gcm.message_id":"1624440092415914","foreground":false}}
2021-06-23 14:51:52.755535+0530 Zimbra[8779:2069018] Push Plugin finish called
2021-06-23 14:51:52.774369+0530 Zimbra[8779:2069018] accept callback finished
2021-06-23 14:51:52.857388+0530 Zimbra[8779:2069018] Push Plugin stopBackgroundTask called
2021-06-23 14:51:52.857550+0530 Zimbra[8779:2069018] Push Plugin handlerObj
2021-06-23 14:51:52.858058+0530 Zimbra[8779:2069018] Push Plugin: stopBackgroundTask (remaining t: 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000)

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

Successfully merging a pull request may close this issue.

1 participant