私は迅速で新しく、ローカル通知を実装する方法がわかりませんいくつかのコードを試しましたが、正確には機能しないので、誰でもiOS
を使用してswift
でローカル通知を実装できますか?速報を使用したローカル通知
0
A
答えて
3
オンラインでたくさんのチュートリアルがありますが、これはGoogleだけでも可能です。ここで
はチュートリアルです:http://jamesonquave.com/blog/local-notifications-in-ios-8-with-swift-part-1/
もここでローカル通知の例です:
let notification = UILocalNotification()
notification.fireDate = date
notification.alertBody = "Alert!"
notification.alertAction = "open"
notification.hasAction = true
notification.userInfo = ["UUID": "reminderID" ]
UIApplication.sharedApplication().scheduleLocalNotification(notification)
26
ここで私は例を共有しています、
ローカル通知のための登録、
@IBAction func registerLocal(sender: AnyObject) {
let notificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)
}
ローカル通知をスケジュールする、
@IBAction func scheduleLocal(sender: AnyObject) {
let notification = UILocalNotification()
notification.fireDate = NSDate(timeIntervalSinceNow: 5)
notification.alertBody = "Hey you! Yeah you! Swipe to unlock!"
notification.alertAction = "be awesome!"
notification.soundName = UILocalNotificationDefaultSoundName
notification.userInfo = ["CustomField1": "w00t"]
UIApplication.sharedApplication().scheduleLocalNotification(notification)
guard let settings = UIApplication.sharedApplication().currentUserNotificationSettings() else { return }
if settings.types == .None {
let ac = UIAlertController(title: "Can't schedule", message: "Either we don't have permission to schedule notifications, or we haven't asked yet.", preferredStyle: .Alert)
ac.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
presentViewController(ac, animated: true, completion: nil)
return
}
}
5 seconds
の後にローカル通知が発生します。
Appcodaのようなチュートリアルもあります。ちょうどあなたが多くを得るgoogle
希望:これは役に立ちます:)
関連する問題
- 1. サーバーデータを使用したiOSローカル通知
- 2. Firebaseを使用したローカル通知
- 3. Unityを使用したローカル通知(Firebase?)
- 4. 速報で通知センタークラッシュ3
- 5. 繰り返しのローカル通知を使用したiPhoneアラーム
- 6. ビーコンを使用したiOSフレームワークのローカル通知の管理
- 7. swiftを使用したローカル通知の取得
- 8. Angular Service Workerを使用したAndroidローカル通知
- 9. GCMを使用した迅速なリモートプッシュ通知
- 10. ローカル通知IOS
- 11. NSUserDefaults +ローカル通知
- 12. ローカル通知
- 13. フレックスモバイルアラーム - ローカル通知
- 14. 速報の1日前または2日前にローカル通知を設定する3
- 15. アラームマネージャを使用してローカル通知をスケジュールするandroid
- 16. iOSでより速いローカル通知を生成するには?
- 17. ローカル通知とプッシュ通知のRx_Swift
- 18. イオン2ローカル通知とプッシュ通知
- 19. ローカル通知とストーリーボード
- 20. WatchKitのローカル通知
- 21. iOSとローカル通知
- 22. Cordovaローカル通知プラグイン
- 23. ローカル通知swift 3
- 24. ユニットテストのローカル通知
- 25. アンドロイドスタジオ用firebaseを使用した通知
- 26. ローカル通知用のカスタムサウンドを選択
- 27. NSTimerを使用した定期的なローカル通知は機能しません。
- 28. iOSでionicを使用したローカル通知が機能しない
- 29. ローカル通知用の「後で通知する」機能
- 30. XamarinフォームAzure通知ハブを使用したプッシュ通知
これについてはGoogleのチュートリアルがたくさんあります。イベントAppleのドキュメンテーションは、どのように動作するかを説明します。 –
[UNUserNotificationCenter](https://developer.apple.com/documentation/usernotifications/unusernotificationcenter)のローカル通知について[このSwift 3の例](https://stackoverflow.com/a/45247943/4754881)をご覧ください。 。 –