MotionInMotion Episode 20 - Local Notifications
Local Notifications - MotionInMotion
- create schema
- redefine entity
schema
,entity
- transformable :notification
- task
- app.cancelLocalNotification(self.notification) if self.notification
- self.notification = UILocalNotification.new.tap do |n|
- n.fireDate = self.due_at
- n.timeZone = NSTimeZone.defaultTimeZone
- n.alertBody = "#{self.name} is due"
- n.alertAction = "View Tasks"
- n.soundName = UILocalNotificationDefaultSoundName
- n.applicationIconBadgeNumber = 1
- app.scheduleLocalNotification(self.notification)
- reset application badge number
- applicationDidBecomeActive(application)
- application.applicationIconBadgeNumber = 0
- applicationDidBecomeActive(application)
- application didReceiveLocalNotification
- if application.applicationState == UIApplicationStateActive
- application.applicationIconBadgeNumber = 0
- UIAlertView.new.tap { |a|
- application.applicationIconBadgeNumber = 0
- if application.applicationState == UIApplicationStateActive
gem 'motion-takeoff'
- def applicationDidBecomeActive(application)
- messages.schedule launch:3, title:"Quick Tip:", message:"This is the 3rd time you've launched this application!"