Advertisement
Guest User

Untitled

a guest
Nov 24th, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1.  
  2. // ユーザーに通知許可を確認
  3. UIApplication.sharedApplication().registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil))
  4.  
  5. let notification = UILocalNotification()
  6. // 10秒後に通知
  7. notification.fireDate = NSDate(timeIntervalSinceNow: 10)
  8. notification.timeZone = NSTimeZone.defaultTimeZone()
  9. notification.alertBody = "Alert Body"
  10. notification.alertAction = "OK"
  11.  
  12. // Custom Sound
  13. notification.soundName = "sample.mp3";
  14. // Default Sound
  15. notification.soundName = UILocalNotificationDefaultSoundName
  16. UIApplication.sharedApplication().scheduleLocalNotification(notification);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement