{"id":6099,"date":"2022-06-23T13:25:51","date_gmt":"2022-06-23T05:25:51","guid":{"rendered":"http:\/\/123.57.164.21\/?p=6099"},"modified":"2022-06-23T13:25:51","modified_gmt":"2022-06-23T05:25:51","slug":"ios-10%e4%bb%a5%e9%99%8d%e3%81%aenotification%e3%81%ae%e5%9f%ba%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=6099","title":{"rendered":"iOS 10\u4ee5\u964d\u306eNotification\u306e\u57fa\u672c"},"content":{"rendered":"\n<p><strong><a href=\"https:\/\/qiita.com\/aokiplayer\/items\/3f02453af743a54de718#%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB\"><\/a>\u306f\u3058\u3081\u306b<\/strong><\/p>\n\n\n\n<ul><li>\u3053\u308c\u307e\u3067\u3001\u30ed\u30fc\u30ab\u30eb\u901a\u77e5\u306b\u306fUIUserNotification\u3092\u5229\u7528\u3057\u3066\u304d\u307e\u3057\u305f<\/li><li>\u304c\u3001iOS 10\u3067\u306fdeprecated\u306b\u306a\u308a\u307e\u3057\u305f<\/li><li>\u3053\u3053\u3067\u306f\u3001iOS 10\u4ee5\u964d\u306e\u30ed\u30fc\u30ab\u30eb\u901a\u77e5\u306e\u65b9\u6cd5\u306e\u57fa\u672c\u3092\u8a18\u8f09\u3057\u307e\u3059<\/li><li>\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3082\u540c\u69d8\u306eAPI\u3092\u4f7f\u3063\u3066\u307e\u3059\u304c\u3001\u4eca\u56de\u306f\u3088\u308a\u4ed5\u7d44\u307f\u306e\u5358\u7d14\u306a\u30ed\u30fc\u30ab\u30eb\u901a\u77e5\u3067\u8aac\u660e\u3057\u307e\u3059<\/li><\/ul>\n\n\n\n<p><strong>\u691c\u8a3c\u74b0\u5883<\/strong><\/p>\n\n\n\n<ul><li>Xcode 8.2.1<\/li><li>iOS 10.2<\/li><li>Swift 3<\/li><\/ul>\n\n\n\n<p><strong><a href=\"https:\/\/qiita.com\/aokiplayer\/items\/3f02453af743a54de718#%E5%A4%A7%E3%81%8D%E3%81%8F%E5%A4%89%E3%82%8F%E3%81%A3%E3%81%9F%E8%A6%8B%E3%81%9F%E7%9B%AE\"><\/a>\u5927\u304d\u304f\u5909\u308f\u3063\u305f\u898b\u305f\u76ee<\/strong><\/p>\n\n\n\n<ul><li>\u30c0\u30a4\u30a2\u30ed\u30b0\u5f62\u5f0f\u306f\u306a\u304f\u306a\u3063\u3066\u3001\u898b\u305f\u76ee\u4e0a\u306f\u30d0\u30ca\u30fc\u3082\u30a2\u30e9\u30fc\u30c8\u3082\u753b\u9762\u4e0a\u90e8\u306e\u8868\u793a\u306b\u5909\u308f\u308a\u307e\u3057\u305f<ul><li>\u30d0\u30ca\u30fc\u306f5\u79d2\u7a0b\u5ea6\u3067HOME\u753b\u9762\u304b\u3089\u8868\u793a\u304c\u6d88\u3048\u308b<\/li><li>\u30a2\u30e9\u30fc\u30c8\u306f\u30e6\u30fc\u30b6\u304c\u4f55\u3089\u304b\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u53d6\u308b\u307e\u3067HOME\u753b\u9762\u306b\u6b8b\u308b<\/li><\/ul><\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-23-585x1024.png\" alt=\"\" class=\"wp-image-6101\" width=\"352\" height=\"616\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-23-585x1024.png 585w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-23-171x300.png 171w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-23-230x403.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-23-350x613.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-23-480x840.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-23.png 762w\" sizes=\"(max-width: 352px) 100vw, 352px\" \/><\/figure><\/div>\n\n\n\n<p><strong><a href=\"https:\/\/qiita.com\/aokiplayer\/items\/3f02453af743a54de718#%E7%99%BB%E5%A0%B4%E3%81%99%E3%82%8B%E3%82%B3%E3%83%B3%E3%83%9D%E3%83%BC%E3%83%8D%E3%83%B3%E3%83%88\"><\/a>\u767b\u5834\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/strong><\/p>\n\n\n\n<ul><li>\u3053\u308c\u3089\u306fUIKit\u3067\u306f\u306a\u304fUserNotifications\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306b\u542b\u307e\u308c\u308b\u306e\u3067\u3001\u5229\u7528\u306b\u306fimport\u304c\u5fc5\u8981\u3067\u3059<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-24-1024x671.png\" alt=\"\" class=\"wp-image-6102\" width=\"520\" height=\"340\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-24-1024x671.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-24-300x197.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-24-768x503.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-24-830x544.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-24-230x151.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-24-350x229.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-24-480x314.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-24.png 1438w\" sizes=\"(max-width: 520px) 100vw, 520px\" \/><\/figure><\/div>\n\n\n\n<p><strong><a href=\"https:\/\/qiita.com\/aokiplayer\/items\/3f02453af743a54de718#%E9%80%9A%E7%9F%A5%E3%82%92%E8%A1%8C%E3%81%86%E3%81%9F%E3%82%81%E3%81%AE%E6%BA%96%E5%82%99\"><\/a>\u901a\u77e5\u3092\u884c\u3046\u305f\u3081\u306e\u6e96\u5099<\/strong><\/p>\n\n\n\n<p><strong><a href=\"https:\/\/qiita.com\/aokiplayer\/items\/3f02453af743a54de718#%E3%83%A6%E3%83%BC%E3%82%B6%E3%81%B8%E9%80%9A%E7%9F%A5%E8%A8%B1%E5%8F%AF%E3%82%92%E8%A6%81%E6%B1%82\"><\/a>\u30e6\u30fc\u30b6\u3078\u901a\u77e5\u8a31\u53ef\u3092\u8981\u6c42<\/strong><\/p>\n\n\n\n<ul><li>\u3053\u308c\u307e\u3067\u3068\u540c\u69d8\u3001\u901a\u77e5\u3092\u884c\u3046\u305f\u3081\u306b\u306f\u30e6\u30fc\u30b6\u306b\u8a31\u53ef\u3092\u5f97\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059<ul><li>\u5834\u6240\u7684\u306b\u306f\u3001\u30a2\u30d7\u30ea\u8d77\u52d5\u6642\u306b\u547c\u3070\u308c\u308bapplication(_:didFinishLaunchingWithOptions:)\u304c\u3088\u3044\u3067\u3057\u3087\u3046<\/li><\/ul><\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {\n\n    \/\/ notification center (singleton)\n    let center = UNUserNotificationCenter.current()\n\n    \/\/ ------------------------------------\n    \/\/ \u524d\u6e96\u5099: \u30e6\u30fc\u30b6\u306b\u901a\u77e5\u306e\u8a31\u53ef\u3092\u6c42\u3081\u308b\n    \/\/ ------------------------------------\n\n    \/\/ request to notify for user\n    center.requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in\n        if granted {\n            print(\"Allowed\")\n        } else {\n            print(\"Didn't allowed\")\n        }\n    }\n\n    return true\n}<\/pre>\n\n\n\n<p><strong><a href=\"https:\/\/qiita.com\/aokiplayer\/items\/3f02453af743a54de718#%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%AB%E3%83%86%E3%82%B4%E3%83%AA%E3%82%92%E7%94%A8%E6%84%8F\"><\/a>\uff08\u30aa\u30d7\u30b7\u30e7\u30f3\uff09\u30ab\u30c6\u30b4\u30ea\u3092\u7528\u610f<\/strong><\/p>\n\n\n\n<ul><li>\u5358\u7d14\u306a\u901a\u77e5\u306f\u3001\u305f\u3060\u306e\u30d0\u30ca\u30fc\u72b6\u3067\u3042\u308a\u3001\u30bf\u30c3\u30d7\u3059\u308b\u3068\u5bfe\u8c61\u306e\u30a2\u30d7\u30ea\u304c\u8d77\u52d5\u3057\u307e\u3059<\/li><li>\u304c\u3001\u30ab\u30b9\u30bf\u30e0Action\uff08\u30dc\u30bf\u30f3\u3060\u3068\u601d\u3048\u3070OK\uff09\u3092\u7528\u610f\u3057\u305f\u96db\u5f62\u3092\u6e96\u5099\u3057\u3066\u304a\u304f\u3068\u3001\u901a\u77e5\u3092\u767a\u884c\u3059\u308b\u969b\u306b\u5229\u7528\u3067\u304d\u307e\u3059<ul><li>\u5225\u306e\u8a18\u4e8b\u3067\u3001\u3044\u305a\u308c\u66f8\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059<\/li><\/ul><\/li><\/ul>\n\n\n\n<p><strong><a href=\"https:\/\/qiita.com\/aokiplayer\/items\/3f02453af743a54de718#%E3%83%AD%E3%83%BC%E3%82%AB%E3%83%AB%E9%80%9A%E7%9F%A5%E3%82%92%E7%99%BB%E9%8C%B2\"><\/a>\u30ed\u30fc\u30ab\u30eb\u901a\u77e5\u3092\u767b\u9332<\/strong><\/p>\n\n\n\n<ul><li>\u901a\u77e5\u81ea\u4f53\u306f\u3001UNNotificationRequest\u3068\u3057\u3066\u4f5c\u6210\u3057\u307e\u3059\uff08\u4ee5\u4e0brequest\uff09<\/li><li>request\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u60c5\u5831\u3092\u542b\u3081\u307e\u3059<ul><li>\u901a\u77e5\u306e\u5185\u5bb9<ul><li>UNMutableNotificationContent<\/li><\/ul><\/li><li>\u901a\u77e5\u306e\u30bf\u30a4\u30df\u30f3\u30b0\uff08When\/Where\uff09<ul><li>UN\u25cb\u25cb\u25cb\u25cbNotificationTrigger\u30b7\u30ea\u30fc\u30ba<\/li><\/ul><\/li><\/ul><\/li><li>request\u3092UNUserNotificationCenter\u306badd(_:withCompletionHandler:)\u3059\u308b\u3053\u3068\u3067\u3001\u30ed\u30fc\u30ab\u30eb\u901a\u77e5\u3092\u767b\u9332\u3057\u307e\u3059<ul><li>\u6307\u5b9a\u306e\u6642\u9593\u3084\u5834\u6240\u3067\u3001\u901a\u77e5\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308b<\/li><\/ul><\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@IBAction func setNotification(_ sender: UIButton) {\n\n    let seconds = Int(segment.titleForSegment(at: segment.selectedSegmentIndex)!)!\n\n    \/\/ ------------------------------------\n    \/\/ \u901a\u77e5\u306e\u767a\u884c: \u30bf\u30a4\u30de\u30fc\u3092\u6307\u5b9a\u3057\u3066\u767a\u884c\n    \/\/ ------------------------------------\n\n    \/\/ content\n    let content = UNMutableNotificationContent()\n    content.title = \"It's time.\"\n    content.subtitle = \"\\(seconds) seconds elapsed!\"\n    content.body = \"I told you now because you had set \\(seconds) seconds before.\"\n    content.sound = UNNotificationSound.default()\n\n    \/\/ trigger\n    let trigger = UNTimeIntervalNotificationTrigger(timeInterval: Double(seconds),\n                                                    repeats: false)\n\n    \/\/ request includes content &amp; trigger\n    let request = UNNotificationRequest(identifier: \"TIMER\\(seconds)\",\n                                        content: content,\n                                        trigger: trigger)\n\n    \/\/ schedule notification by adding request to notification center\n    let center = UNUserNotificationCenter.current()\n    center.add(request) { (error) in\n        if let error = error {\n            print(error.localizedDescription)\n        }\n    }\n}<\/pre>\n\n\n\n<p><strong><a href=\"https:\/\/qiita.com\/aokiplayer\/items\/3f02453af743a54de718#%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0action%E9%81%B8%E6%8A%9E%E6%99%82%E3%81%AE%E5%87%A6%E7%90%86%E3%82%92%E5%AE%9F%E8%A3%85\"><\/a>\uff08\u30aa\u30d7\u30b7\u30e7\u30f3\uff09\u30ab\u30b9\u30bf\u30e0Action\u9078\u629e\u6642\u306e\u51e6\u7406\u3092\u5b9f\u88c5<\/strong><\/p>\n\n\n\n<ul><li>\u901a\u77e5\u3092\u30bf\u30c3\u30d7\u3057\u305f\u3089\u30a2\u30d7\u30ea\u304c\u8868\u793a\u3055\u308c\u308b\u3060\u3051\u3067\u3042\u308c\u3070\u3001\u3053\u308c\u306f\u4e0d\u8981\u3067\u3059<\/li><li>UNUserNotificationCenterDelegate\u3092\u5229\u7528\u3059\u308b\u3068\u3001\u30ab\u30b9\u30bf\u30e0Action\u306b\u5bfe\u3059\u308b\u51e6\u7406\u304c\u5b9f\u88c5\u3067\u304d\u307e\u3059<ul><li>\u901a\u5e38\u3001\u8a72\u5f53\u30a2\u30d7\u30ea\u304c\u30d5\u30a9\u30a2\u30b0\u30e9\u30a6\u30f3\u30c9\u306e\u5834\u5408\u306b\u306f\u901a\u77e5\u306f\u8868\u793a\u3055\u308c\u307e\u305b\u3093\u304c\u3001\u8868\u793a\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059<\/li><\/ul><\/li><li>\u3053\u308c\u3082\u3001\u5225\u8a18\u4e8b\u3067\u307e\u3068\u3081\u308b\u4e88\u5b9a\u3067\u3059<\/li><\/ul>\n\n\n\n<p><strong>\u307e\u3068\u3081<\/strong><\/p>\n\n\n\n<ul><li>API\u304c\u6574\u7406\u3055\u308c\u3066\u3001\u4f7f\u3044\u3084\u3059\u304f\u306a\u308a\u307e\u3057\u305f<ul><li>delegate\u3068\u306e\u7d44\u307f\u5408\u308f\u305b\u3067\u3001\u30b3\u30fc\u30c9\u3082\u6574\u7406\u3067\u304d\u305d\u3046\u3067\u3059<\/li><\/ul><\/li><li>Extension Point\u3082\u8ffd\u52a0\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u901a\u77e5\u6e08\u307f\u306e\u5185\u5bb9\u3092\u66f4\u65b0\u3082\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f<\/li><li>\u4eca\u56de\u306f\u5358\u7d14\u306b\u901a\u77e5\u3092\u51fa\u3059\u3060\u3051\u3067\u3057\u305f\u304c\u3001\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u306a\u3069\u3082\u307e\u305f\u307e\u3068\u3081\u305f\u3044\u3068\u601d\u3044\u307e\u3059<\/li><li>\u4eca\u56de\u4f5c\u6210\u3057\u305f\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u306f\u3001GitHub\u306b\u7f6e\u304d\u307e\u3057\u305f<ul><li><a href=\"https:\/\/github.com\/aokiplayer\/UserNotificationSample\" rel=\"noreferrer noopener\" target=\"_blank\">UserNotificationSample<\/a><\/li><\/ul><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b \u3053\u308c\u307e\u3067\u3001\u30ed\u30fc\u30ab\u30eb\u901a\u77e5\u306b\u306fUIUserNotification\u3092\u5229\u7528\u3057\u3066\u304d\u307e\u3057\u305f \u304c\u3001iOS 10\u3067 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/6099"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6099"}],"version-history":[{"count":2,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/6099\/revisions"}],"predecessor-version":[{"id":6103,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/6099\/revisions\/6103"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}