Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27165] iOS: The localnotificationaction event always contains the notification identifier instead of the action identifier

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2019-10-04T13:58:35.000+0000
Affected Version/sn/a
Fix Version/sRelease 8.2.1
Componentsn/a
Labelsn/a
ReporterTeun Klijn
AssigneeJan Vennemann
Created2019-06-19T11:02:30.000+0000
Updated2020-11-04T03:51:49.000+0000

Description

*Describe the bug* When adding category with an action to an iOS local notification the localnotificationaction always contains the notification identifier instead of the action identifier. *To Reproduce*

Create a notification action with an identifier

Create a category with the action

Schedule notification with the category

Print the localnotificationaction object

Check the identifier

var ACTION = "action";
var CATEGORY = "category";

function onSchedule() {
  Ti.App.iOS.scheduleLocalNotification({
    date: new Date(new Date().getTime() + 5000),
    alertBody: "Hello",
    identifier: "notification 1",
    category: CATEGORY
  });
}

function onLocalNotificationAction(e) {
  console.log('Action: ' + e.identifier);
}

function onOpen() {
  Ti.App.iOS.addEventListener('localnotificationaction', onLocalNotificationAction);

  var action = Ti.App.iOS.createUserNotificationAction({
    identifier: ACTION,
    title: "My Action",
    activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_FOREGROUND
  });

  var category = Ti.App.iOS.createUserNotificationCategory({
    identifier: CATEGORY,
    actionsForDefaultContext: [action],
    actionsForMinimalContext: [action]
  });

  Ti.App.iOS.registerUserNotificationSettings({
    types: [
      Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT,
      Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND,
      Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE
    ],
    categories: [category]
  });
}

var win = Ti.UI.createWindow();
win.addEventListener('open', onOpen);

var button = Ti.UI.createButton({
  title: "Schedule"
});
button.addEventListener('click', onSchedule);
win.add(button);

win.open();
*Expected behavior* The identifier has the value of the action *Actual behavior* The identifier has the value of the notification *Environment* Titanium SDK version: 7.5.2.GA; 8.0.1.GA I did create a pull request for this, but I want to be sure that it will be picked up: https://github.com/appcelerator/titanium_mobile/pull/10940

Comments

  1. Jan Vennemann 2019-06-19

    PR: https://github.com/appcelerator/titanium_mobile/pull/10940
  2. Samir Mohammed 2019-07-02

    FR Passed on Master.
  3. Christopher Williams 2019-09-17

    Merged PR to master, created an 8_2_X PR intended for 8.2.1 here: https://github.com/appcelerator/titanium_mobile/pull/11226
  4. Samir Mohammed 2019-09-26

    FR Passed on 8_2_X as well.
  5. Christopher Williams 2019-10-02

    merged to 8_2_X
  6. Samir Mohammed 2019-10-04

    Closing ticket, fix verified SDK version 8.3.0.v20191003144543 and 8.2.1.v20191003075717. Test and other information cab be found at: master: https://github.com/appcelerator/titanium_mobile/pull/10940 8_2_X: https://github.com/appcelerator/titanium_mobile/pull/11226

JSON Source