Quantcast
Viewing all articles
Browse latest Browse all 8068

Local Notification issue on iPhone

Hello Everyone ,

                I developing app for reminder. I want to set reminder on user defined ( specific)  time . (for e.g repeated on every day on 9 am ) . I am using following code. But this code is not work properly on sometime. Please give me your valuable feedback on it. (and also  if i want to set reminder for every two hour what should i do.)

app.js
 
    Ti.App.addEventListener('pause',function(e){
       service=Ti.App.iOS.registerBackgroundService({url:'notification_service.js'});
    Ti.API.info("registered background service = "+service);
});
 
*********************************************************
notification_service.js
 
var dateObj = new Date();
 
dateObj.setHours(hour);
dateObj.setMinutes(min);
dateObj.setSeconds(00);
dateObj.setMilliseconds(00);
 
var notification = Ti.App.iOS.scheduleLocalNotification({
                alertBody : 'Reminder',
                alertAction : "Answer it!",
                userInfo : {
                    "id" : 1,
                    "hello" : "world"
                },
                repeat : 'daily',
                date : new Date(dateObj)
            });
 
 
Ti.App.iOS.addEventListener('notification',function(){
Ti.API.info('background event received = '+notification);
Ti.App.currentService.stop();
Ti.App.currentService.unregister();
});

Viewing all articles
Browse latest Browse all 8068

Trending Articles