Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Action Buttons missing on pushes after sending a local notification using cordova-plugins-local-notifications (1.6.0) #682

Open
jopelkey opened this issue Mar 9, 2016 · 4 comments

Comments

@jopelkey
Copy link

jopelkey commented Mar 9, 2016

Expected Behaviour

Push notifications with action buttons defined should work all the time and not be affected by the use of other plugins that handle sending local notifications.

This issue is a continuation of issues #557 and #576 since those were closed for the 1.6.0 release, but this issue is still outstanding in 1.6.0 so I am opening a new issue per request by @macdonst

Actual Behaviour

I have my action buttons working great and doing the background processing when the action buttons are selected - until I also send a local notification to my app using the cordova-plugins-local-notifications plugin., at which point the action buttons on subsequent pushes are no longer visible.

i.e. I have an error path scenario where in the processing of my action button callback, I need to indicate an error occurred. I do this by sending a local notification. After doing so, subsequent remote pushes handled by the phonegap-plugin-push plugin no longer show the action buttons.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

  1. Send first remote push using phonegap-plugin-push (this has action buttons)
  2. During background processing of first push Accept Button
    • send a local notificationusing cordova-plugins-local-notifications
    • do not click on local notification/don't bother to open app
  3. Send second remote push using phonegap-plugin-push (now it no longer shows the action buttons)

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

  • Xcode 7.2
  • IOS 9.2.1 on an Iphone 5
  • cordova cli: 6.0.0
  • cordova-ios: 4.1.0
  • phonegap-plugin-push: 1.6.0
  • cordova-plugin-local-notifications: 0.8.4
  • ngCordova 0.1.24-alpha

Sample Push Data Payload

  • Here's the init config:
config = {
    "ios" : {
        "badge": "true",
        "clearBadge": "true",
        "sound": "true",
        "alert": "true",
        "categories": {
            "verification": {
                "yes": {
                    "callback": "window.acceptVerification",
                    "title": "Accept",
                    "foreground": false,
                    "destructive": false
                },
                "no": {
                    "callback": "window.rejectVerification",
                    "title": "Reject",
                    "foreground": false,
                    "destructive": true
                }
            }
        }
    }
}

  • Here's the push payload (taken from the push plugin logging):

    aps =     {
        alert =         {
            body = "Some tenant name\nLogin Verification\nsome.tenant.com";
        };
        badge = 2;
        category = verification;
        sound = default;
    };
    callback = "window.acceptVerification";
    notId = "NOTID-1457538939";
    pushPayload =     {
        customPayload: "our custom content here"
    };
    }
    

Sample Code that illustrates the problem

  • Here's some sample callback definitions: this scenario just uses the window.acceptVerification callback
window.acceptVerification = function(data) {
    console.log('PushService: handle Accept Verification Button'); 
    console.log("PushSvc: Accept Button Data: " + JSON.stringify(data));

    var notId = notificationData.additionalData.notId
    console.log("PushSvc: handle action button: notId = " + notId);

    push.setApplicationIconBadgeNumber(
        function(data) {
            console.log("PushSvc: clear badge count: " + data);
        },
        function(err) {
            console.log(
                "PushSvc: Failed to clear badge count: " + err);
        },
        0);

    var localNotifOptions = {
        id: 0,
        title: 'Local Title',
        text: 'Local notification message'
    };
    $cordovaLocalNotification.schedule(localNotifOptions);

    push.finish(
        function success() {
            console.log("PushSvc: Local Notification Options: " + JSON.stringify(localNotifOptions));
        },
        function error() {
            console.log("PushSvc: push.finish failed");
        },
        notId);
}

window.rejectVerification = function(data) {
    console.log('PushService: handle Reject Verification Button');
    push.finish(function() {
        console.log('reject finished');
    });
}

Logs taken while reproducing problem

2016-03-09 08:54:52.839 Mobile Auth[477:281903] Apache Cordova native platform version 4.1.0 is starting.
2016-03-09 08:54:52.841 Mobile Auth[477:281903] Multi-tasking -> Device: YES, App: YES
2016-03-09 08:54:53.030 Mobile Auth[477:281903] Using UIWebView
2016-03-09 08:54:53.032 Mobile Auth[477:281903] [CDVTimer][handleopenurl] 0.163019ms
2016-03-09 08:54:53.035 Mobile Auth[477:281903] [CDVTimer][intentandnavigationfilter] 2.317965ms
2016-03-09 08:54:53.035 Mobile Auth[477:281903] [CDVTimer][gesturehandler] 0.126004ms
2016-03-09 08:54:53.036 Mobile Auth[477:281903] [CDVTimer][localnotification] 1.034975ms
2016-03-09 08:54:53.037 Mobile Auth[477:281903] [CDVTimer][localnotification] 0.016034ms
2016-03-09 08:54:53.064 Mobile Auth[477:281903] [CDVTimer][splashscreen] 27.602971ms
2016-03-09 08:54:53.065 Mobile Auth[477:281903] [CDVTimer][keyboard] 0.438035ms
2016-03-09 08:54:53.065 Mobile Auth[477:281903] [CDVTimer][TotalPluginStartup] 33.240020ms
2016-03-09 08:54:53.076 Mobile Auth[477:281903] createNotificationChecker
2016-03-09 08:54:53.076 Mobile Auth[477:281903] not coldstart
2016-03-09 08:54:53.079 Mobile Auth[477:281903] active
2016-03-09 08:54:53.079 Mobile Auth[477:281903] PushPlugin skip clear badge


2016-03-09 08:54:54.678 Mobile Auth[477:281903] PushSvc: Entering register
2016-03-09 08:54:54.678 Mobile Auth[477:281903] PushSvc: platform:ios
2016-03-09 08:54:54.678 Mobile Auth[477:281903] PushSvc: init config:
{"ios":{"badge":"true","clearBadge":"true","sound":"true","alert":"true","categories":{"verification":{"yes":{"callback":"window.acceptVerification","title":"Verify","foreground":false,"destructive":false},"no":{"callback":"window.rejectVerification","title":"Reject","foreground":false,"destructive":true}}}}}2016-03-09 08:54:54.689 Mobile Auth[477:281967] Push Plugin register called2016-03-09 08:54:54.690 Mobile Auth[477:281967] PushPlugin.register: setting badge to true2016-03-09 08:54:54.690 Mobile Auth[477:281967] PushPlugin.register: clear badge is set to 1
2016-03-09 08:54:54.690 Mobile Auth[477:281967] PushPlugin.register: better button setup
2016-03-09 08:54:54.690 Mobile Auth[477:281967] categories: key verification
2016-03-09 08:54:54.690 Mobile Auth[477:281967] Adding category verification
2016-03-09 08:54:54.691 Mobile Auth[477:281967] GCM Sender ID (null)
2016-03-09 08:54:54.691 Mobile Auth[477:281967] Using APNS Notification
2016-03-09 08:54:54.712 Mobile Auth[477:281903] Push Plugin register success: <538cf9ed f31f7887 fa36d3b4 26f5006a 68e6497d 693efd65 94d3a303 85e00967>

2016-03-09 08:55:45.000 Mobile Auth[477:281903] Push Plugin handleActionWithIdentifier window.acceptVerification
2016-03-09 08:55:45.001 Mobile Auth[477:281903] Push Plugin userInfo {
    aps =     {
        alert =         {
            body = "Some tenant name\nLogin Verification\nsome.tenant.com";
        };
        badge = 2;
        category = verification;
        sound = default;
    };
    callback = "window.acceptVerification";
    notId = "NOTID-1457538939";
    pushPayload =     {
        customPayload: "our custom content here"
    };
}
2016-03-09 08:55:45.001 Mobile Auth[477:281903] Push Plugin notId NOTID-1457538939
2016-03-09 08:55:45.001 Mobile Auth[477:281903] Notification received
2016-03-09 08:55:45.003 Mobile Auth[477:281903] Push Plugin key: sound
2016-03-09 08:55:45.004 Mobile Auth[477:281903] Push Plugin key: alert
2016-03-09 08:55:45.004 Mobile Auth[477:281903] Push Plugin key: badge
2016-03-09 08:55:45.004 Mobile Auth[477:281903] Push Plugin key: category
2016-03-09 08:55:45.013 Mobile Auth[477:281903] PushSvc: handle Accept Verification Button
2016-03-09 08:55:45.013 Mobile Auth[477:281903] PushSvc: Accept Button Data: {"additionalData":{"category":"verification","pushPayload":{"request":{"uri":"uri","userId":"userId","requestTimestamp":1457538939,"tenantId":"tenantId","tenantName":"sendMsg.js fake tenant","requestId":7259935,"loginUri":"sendMsg.fake.com","responseUri":"responseUri"},"authenticatorId":"authId"},"foreground":false,"coldstart":false,"notId":"NOTID-1457538939","callback":"window.acceptVerification"},"message":"Some tenant name\nLogin Verification\nsome.tenant.com","count":2,"sound":"default"}
2016-03-09 08:55:45.013 Mobile Auth[477:281903] PushSvc: handle action button: notId = NOTID-1457538939

2016-03-09 08:55:45.045 Mobile Auth[477:281903] PushSvc: clear badge count: app badge count set to 0
2016-03-09 08:55:45.141 Mobile Auth[477:281903] Push Plugin finish called

2016-03-09 08:55:45.182 Mobile Auth[477:281903] PushSvc: Local Notification Options: {"id":0,"title":"Verification Issue","text":"Enter app to retry."}
2016-03-09 08:55:45.302 Mobile Auth[477:281903] Push Plugin stopBackgroundTask called
2016-03-09 08:55:45.302 Mobile Auth[477:281903] Push Plugin handlerObj
2016-03-09 08:55:45.304 Mobile Auth[477:281903] Push Plugin: stopBackgroundTask (remaining t: 29.686749)

I send a 2nd push here: there's no more logging since it doesn't have any action buttons shown.
FYI - I can still click on the notification and it opens the app and processes the notification correctly in the foreground, so that portion of the push still works.

@panaggio
Copy link

Any idea on where the bug might be? Wild guesses accepted.

@macdonst macdonst modified the milestone: Release 1.8.0 Sep 9, 2016
@dcousens
Copy link

dcousens commented Jan 6, 2017

Is this still happening?

@manuman94
Copy link

Yes, it does. Today I tried to install local-notifications plugin to my Ionic 2 project and then I can't build my project.

Someone knows how to achieve this? I want push plugin only to send additional data and manage myself notifications, not server.

@Pigsnuck
Copy link

Pigsnuck commented Dec 1, 2017

cordova-plugin-local-notifications conflicts with this plugin and has known issues. Unfortunately, I haven't found a workaround yet, but I would love to know if anyone else has.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

6 participants