question

fivefinger2015 avatar image
fivefinger2015 asked

How can i use CancelNotification?

PlayFabAndroidPlugin.CancelNotification doesn't work. (for local notification)

It does not work even if I input the argument entered in PlayFabAndroidPlugin.ScheduleNotification.

Creating a new json string(same content) or changing the contents of the PlayFabNotificationPackage did not work.

How exactly should I put the arguments?

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

fivefinger2015 avatar image fivefinger2015 commented ·

Can anyone help me?

0 Likes 0 ·
brendan avatar image
brendan answered

Sorry for the delay getting back to you on this - the only thing you should have to pass in is the same notification string you passed into ScheduleNotification, but it does need to be exactly the same, so that the plugin can find the correct message to remove from the scheduler. If that's not working for you, can you provide specifics on your test case?

Also, I do see that the plugin source mentioned in the readme is not in the current SDK release, so I've opened a bug with the tools team to get that addressed.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

fivefinger2015 avatar image
fivefinger2015 answered

Below is the code I'm using, not much different from the one in Help.

    // Create notificaion on application pause
    DateTime sDate = DateTime.Now;
    sDate = sDate.AddSeconds(10);

    PlayFabNotificationPackage ScheduledNotification = new PlayFabNotificationPackage()
    {
        ScheduleType = ScheduleTypes.ScheduledDate,
        Message = Localization.Get("LocalPushFullShoes"),
        Title = Localization.Get("Title"),
        Id = "ShoesFullPush",
        ScheduleDate = sDate
    };
    _currentLocalPushJson = PlayFab.Json.JsonWrapper.SerializeObject(ScheduledNotification);
    PlayFabAndroidPlugin.ScheduleNotification(_currentLocalPushJson, sDate);
    .
    .

    // Cancel notification on application resume
    PlayFabAndroidPlugin.CancelNotification(_currentLocalPushJson);

ScheduleNotification works fine.

Thank you.

6 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

And if you set the time to more like 10 minutes (so that you have time for debugging), what do you see when you pass in that same _currentLocalPushJson to CancelNotification and step through the call? At what point does it fail?

0 Likes 0 ·
fivefinger2015 avatar image fivefinger2015 brendan commented ·

I set it to 10 minutes as you told me and tested it several times, but the results were the same.

And a minor, but odd thing was found, and the notification occurred a few minutes(2~5) after the scheduled time on the ScheduleNotification.

The test was done in the following process.

1. Deactivate application (call ScheduleNotification)

2. Activate application immediately (call CancelNotification)

And the contents of _currentLocalPushJson were exactly the same.

0 Likes 0 ·
brendan avatar image brendan fivefinger2015 commented ·

The time is local to the device, so your phone's time is the one to check, in terms of the delivery schedule. But to be clear, what I was asking was that you set the time longer so that the time didn't elapse while you were stepping into the call in the debugger. The thing to do would be to step over the ScheduleNotification call and check to see what the Log output shows. You should see an "Alarm was set to" output with the time to "delivery" the message. After you have confirmed that, step over the CancelNotification call and check if there's a log output. If so, what does that output show?

0 Likes 0 ·
Show more comments
fivefinger2015 avatar image fivefinger2015 brendan commented ·

Failure means that the notification is not canceled and occurs as scheduled even though CancelNotification is called.

0 Likes 0 ·
marcowilliamspf avatar image
marcowilliamspf answered

@fivefinger2015 I will have to run some tests to see if the CancelNotification is working as expected. I'm out for a couple of days and will look into this on Friday.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

fivefinger2015 avatar image fivefinger2015 commented ·

Ok. I'll wait.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.