简体   繁体   中英

Cannot delete local notifications in Appcelerator Titanium for iOS

I developed an app for a client in which the user can set local notifications. The issue is when the user tries to delete the alarm/notification from their list, the notification still fires (for repeating alarms). I've tried to cancel all notifications on load and then setting each one notification up again as well as other methods, but nothing seems to work. Is there a solution to this? Has anyone else experienced this? It should be a pretty basic task to accomplish.

Here's the code I'm using to remove the notification from the server db as well as from within the phone's local notification storage:

    tbl.addEventListener('delete',function(e){
            var rowIndex = e.rowIndex;
            tbl.deleteRow(rowIndex);

            var appReq = Ti.Network.createHTTPClient();
                appReq.open('POST', app.appurl + 'actions.php');
                //LOAD
                appReq.onload = function(){
                    Ti.API.info(this.responseText);
                    var appResp = JSON.parse(this.responseText);//JSON resp

                    if(appResp.rsp == 'OK')
                    {
                        app.alarms[e.rowData.cancel_id].cancel();
                        view.getAlarms();

                    }else
                    {
                        alert(appResp.msg);
                    }
                };

                //ERROR
                appReq.onerror = function(e){
                    Ti.API.info(e.error);
                };

                //DATA
                var data = {
                    id:e.rowData.id,
                    action:'removealarm'
                };

                //SEND
                Ti.API.info('sending: ' + JSON.stringify(data));
                appReq.send(data);
        });

**NOTE: This code seemed to work for my device but not the client's, I just need to make sure this would be the proper method.

要取消所有待处理的通知,请调用Ti.App.iOS.cancelAllLocalNotifications()方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM