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 Interactive Push Background Mode Doesn't Seem to work. #70

Open
ucswift opened this issue Feb 2, 2016 · 3 comments
Open

iOS Interactive Push Background Mode Doesn't Seem to work. #70

ucswift opened this issue Feb 2, 2016 · 3 comments

Comments

@ucswift
Copy link

ucswift commented Feb 2, 2016

Using the latest plugin version 3.0.6, I have the iOS interactive push plugin wired up. When it comes in the user selects an action, but nothing happens (testing from the shade when the device is logged in).

This is the output from the log when the notification is received:
: Device Paused Event
: Device Paused Event - In GeoService
: Stopping Geolocation
: didReceiveNotification
: Notification received
: Msg: {"sound":"beep.caf","content-available":"1","alert":"Call Test iOS9 Push phonegap-build#104","category":"CALLS","badge":"1","eventCode":"C40946","identifier":"RESP",foreground:"0"}

Then after the app is activated the log reflects processing of the action:
: Push Notification: On Notificaiton Recieved Event
: {"sound":"beep.caf","content-available":"1","alert":"Call Test iOS9 Push phonegap-build#104","category":"CALLS","badge":"1","eventCode":"C40946","identifier":"RESP","foreground":"0"}
: Processing iOS Responding Push Action
: CallId 40946
: Device Resumed Event
: Setting local data

During testing the app was in memory and it was also tested with the app not in memory (coldstart), this is the log output:
: assertion failed: 12H143: libxpc.dylib + 71768 [C9F3C08A-8A3B-3849-A905-D24911240853]: 0x7d
: Apache Cordova native platform version 3.8.0 is starting.
: Multi-tasking -> Device: YES, App: YES
: Unlimited access to network resources
: [CDVTimer][statusbar] 25.731027ms
: [CDVTimer][file] 2.654016ms
: [CDVTimer][statusbar] 0.010014ms
: [CDVTimer][uniquedeviceid] 0.064969ms
: [CDVTimer][threedeetouch] 0.048041ms
: [CDVTimer][splashscreen] 9.157002ms
: [CDVTimer][TotalPluginStartup] 38.909018ms
: Notification received

In the coldstart scenario the notification is just gone, when the app is activated by the user the JavaScript callback is not called.

@ucswift
Copy link
Author

ucswift commented Feb 2, 2016

Just adding some more context:

Here is the plugin reg:
var pushPlugin = window.plugins.pushNotification;
pushPlugin.register(tokenHandler, pushErrorHandler, { "badge": "true", "sound": "true", "alert": "true", "ecb": "pushOnNotificationEvent" });

Here is the tokenHandler JS:
tokenHandler = function (result) {
console.log('REGISTERED with APNS Server:' + JSON.stringify(result));

var elem = angular.element(document.querySelector('[ng-app]'));
var injector = elem.injector();
var service = injector.get('pushService');

service.registerWithResgrid(result, 1, null);

var pushPlugin = window.plugins.pushNotification;

var respondingActionSmall = {
    identifier: 'RESP', // mandatory
    title: 'Resp', // mandatory
    activationMode: pushPlugin.UserNotificationActivationMode.Background,
    //activationMode: pushPlugin.UserNotificationActivationMode.Foreground, // default: Background
    destructive: false, // default: false
    authenticationRequired: false // default: false Is the PIN required to be entered
};

var notRespondingActionSmall = {
    identifier: 'NOTRESP',
    title: 'Not Resp',
    activationMode: pushPlugin.UserNotificationActivationMode.Background,
    destructive: true,
    authenticationRequired: false
};

var respondingAction = {
    identifier: 'RESPONDING', // mandatory
    title: 'Responding', // mandatory
    activationMode: pushPlugin.UserNotificationActivationMode.Background,
    //activationMode: pushPlugin.UserNotificationActivationMode.Foreground, // default: Background
    destructive: false, // default: false
    authenticationRequired: false // default: false Is the PIN required to be entered
};

var notRespondingAction = {
    identifier: 'NOTRESPONDING',
    title: 'Not Responding',
    activationMode: pushPlugin.UserNotificationActivationMode.Background,
    destructive: true,
    authenticationRequired: false
};

var callCategory = {
    identifier: 'CALLS', // mandatory
    actionsForDefaultContext: [respondingAction, notRespondingAction], // mandatory
    actionsForMinimalContext: [respondingActionSmall, notRespondingActionSmall] // mandatory
};

// Register the category and the other interactive settings.
pushPlugin.registerUserNotificationSettings(
    // the success callback which will immediately return (APNs is not contacted for this)
        pushSuccessHandler,
    // called in case the configuration is incorrect
        pushErrorHandler,
    {
        // asking permission for these features
        types: [
            pushPlugin.UserNotificationTypes.Alert,
            pushPlugin.UserNotificationTypes.Badge,
            pushPlugin.UserNotificationTypes.Sound
        ],
        // register these categories
        categories: [
            callCategory
        ]
    }
);

// Your iOS push server needs to know the token before it can push to this device
// here is where you might want to send it the token for later use.

}

@mitkodev
Copy link

mitkodev commented Feb 6, 2016

Hey, let's continue the discussion from #69 here
So on monday i'll add some checks about the current ios version and fix the handleActionWithIdentifier issue for ios8 and ios9, cause currently i don't have a device with ios8 and can't validate it, before commiting

About the other issue - do you expect someone to click a button when you send a push with content-available key? The "didReceiveRemoteNotification with fetchCompletionHandler" event handler lacks the "identifier" value, that is received in the "handleActionWithIdentifier" handler, that's why is is not part of the data object in the callback. Here is my log when I sent a push with content-available and sound:

<Warning>: didReceiveRemoteNotification with fetchCompletionHandler <Warning>: Notification received <Warning>: JS: iOS notification received: {"alert":"message","category":"READ_CATEGORY","sound":"default","content-available":"1","foreground":"0"} <Warning>: Push Plugin notificationProcessed called <Warning>: silentNotificationHandler called

and right after that if i click the button that is part of the notification i get into this:
<Warning>: handleActionWithIdentifier <Warning>: Notification received <Warning>: JS: iOS notification received: {"alert":"message","category":"READ_CATEGORY","sound":"default","content-available":"1","identifier":"READ_IDENTIFIER","foreground":"0"} <Warning>: Push Plugin notificationProcessed called <Warning>: remoteNotificationHandler called

Would you say how those events look when you test it on your device, so we can come to a conclusion about this.

@ucswift
Copy link
Author

ucswift commented Feb 15, 2016

I was testing content-available to try and attempt to get it to work basically. I don't think there is a usage scenario where it should be required to be coupled with Interactive push. My assumption would be that content-available=1 would be used for background push payloads only.

After some work on the plugin I had to comment out:
handleActionWithIdentifier: forRemoteNotification: withResponseInfo
To be able to get interactive push to work in all scenarios on both iOS8 and iOS9. For whatever reason I couldn't get Interactive buttons to work with coldstart on iOS9 with this method, even though I used the same logic for handleActionWithIdentifier: forRemoteNotification.

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

2 participants