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

fix(ios): cancel pending local notifications (8_0_X) #10583

Merged
merged 2 commits into from
Jan 9, 2019

Conversation

janvennemann
Copy link
Contributor

@janvennemann janvennemann added this to the 8.0.0 milestone Jan 8, 2019
@janvennemann janvennemann changed the title fix(ios): cancel pending local notifications fix(ios): cancel pending local notifications (8_0_X) Jan 8, 2019
@ssjsamir ssjsamir self-requested a review January 9, 2019 10:43
Copy link
Contributor

@ssjsamir ssjsamir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FR Passed Using the following test case

var window = Ti.UI.createWindow({
  backgroundColor: 'white'
});

var button = Ti.UI.createButton({
  title: 'Schedule'
});

var isScheduling = true;
button.addEventListener('click', function() {
  if (isScheduling) {
    var alarmObject = {
      date: new Date(new Date().getTime() + 20000),
      alertBody: "Hello world",
      badge: 1,
      identifier: "test_id",
      sound: 'default'
    };

    console.log('schedule: ' + JSON.stringify(alarmObject));

    Ti.App.iOS.scheduleLocalNotification(alarmObject);

    button.title = "Cancel";
  } else {
    Ti.App.iOS.UserNotificationCenter.getPendingNotifications(function(result) {
      if (result && result.notifications && result.notifications.length) {
        console.log(result.notifications);
        var _;
        var notificationsToCancel = result.notifications

        console.log('cancel these: ' + JSON.stringify(notificationsToCancel));

        if (notificationsToCancel) {
          Ti.App.iOS.UserNotificationCenter.removePendingNotifications(notificationsToCancel);
        }
      }
    });

    button.title = "Schedule";
  }

  isScheduling = !isScheduling;
});

window.add(button);

window.addEventListener('open', function() {
  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
    ]
  });
});

window.open();

Application no longer shows an error unlike 7.5.0.GA.

Test Environment

iPhone 6s plus (9.3) Sim
APPC CLI: 7.0.0
Operating System Name: Mac OS Mojave
Operating System Version: 10.14.2
Node.js Version: 8.9.1
Xcode 10.1

@build
Copy link
Contributor

build commented Jan 9, 2019

Fails
🚫

🔬 There are library changes, but no changes to the unit tests. That's OK as long as you're refactoring existing code, but will require an admin to merge this PR. Please see README.md#unit-tests for docs on unit testing.

🚫 Tests have failed, see below for more information.
Messages
📖

💾 Here's the generated SDK zipfile.

📖 ❌ 3 tests have failed There are 3 tests failing and 449 skipped out of 2983 total tests.

Tests:

Classname Name Time Error
android.Titanium.UI.Layout TIMOB-23372 #3 5.754 timeout of 5000ms exceeded
android.Titanium.UI.TabbedBar Labels update 3.171 tabbedBar.labels.get is not a function
ios.Titanium.UI.TabbedBar Labels update 0.006 tabbedBar.labels.get is not a function. (In 'tabbedBar.labels.get(1)', 'tabbedBar.labels.get' is undefined)

Generated by 🚫 dangerJS against c577869

@sgtcoolguy sgtcoolguy merged commit a061bab into tidev:8_0_X Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants