Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. func notification(){
  2. let content = UNMutableNotificationContent()
  3. content.title = "GPS alert message"
  4. // content.subtitle = "Do you know?"
  5. content.body = "Your GPS detect vibration!!"
  6. content.badge = 1
  7. content.sound = UNNotificationSound.default()
  8. let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)
  9. let request = UNNotificationRequest(identifier: "timerDone", content: content, trigger: trigger)
  10. UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
  11.  
  12. }
  13.  
  14. func notification(){
  15.  
  16.  
  17. let content = UNMutableNotificationContent()
  18. content.title = "GPS alert message"
  19. // content.subtitle = "Do you know?"
  20. content.body = "Your GPS detect vibration!!"
  21. content.badge = 1
  22. content.sound = UNNotificationSound.default()
  23. let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)
  24. let request = UNNotificationRequest(identifier: "timerDone", content: content, trigger: trigger)
  25.  
  26. UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
  27.  
  28. }
  29.  
  30. func someBackgroundTask(timer:Timer) {
  31. DispatchQueue.global(qos: DispatchQoS.background.qosClass).async {
  32. //print("do some background task")
  33. self.getData()
  34. DispatchQueue.main.async {
  35. //self.updatMarker()
  36. }
  37. }
  38. }
  39.  
  40. Timer.scheduledTimer(withTimeInterval: 5.0, repeats: true) {
  41. timer in
  42.  
  43. self.someBackgroundTask(timer: timer)
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement