{"id":427900,"date":"2021-04-18T06:10:19","date_gmt":"2021-04-17T22:10:19","guid":{"rendered":"http:\/\/4563.org\/?p=427900"},"modified":"2021-04-18T06:10:19","modified_gmt":"2021-04-17T22:10:19","slug":"%e8%af%b7%e6%95%99%e4%b8%8b-ios-%e6%8e%a8%e9%80%81-appdelegate-swift-%e8%af%a5%e6%80%8e%e4%b9%88%e5%86%99%ef%bc%8c%e6%88%96%e8%80%85%e7%bc%ba%e5%b0%91%e4%ba%86%e4%bb%80%e4%b9%88%e6%ad%a5%e9%aa%a4","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=427900","title":{"rendered":"\u8bf7\u6559\u4e0b iOS \u63a8\u9001 AppDelegate. Swift \u8be5\u600e\u4e48\u5199\uff0c\u6216\u8005\u7f3a\u5c11\u4e86\u4ec0\u4e48\u6b65\u9aa4"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u6559\u4e0b iOS \u63a8\u9001 AppDelegate. Swift \u8be5\u600e\u4e48\u5199\uff0c\u6216\u8005\u7f3a\u5c11\u4e86\u4ec0\u4e48\u6b65\u9aa4               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : LollipopKit <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u9879\u76ee\u662f\u4f7f\u7528\u7684 flutter\uff0c\u7b2c\u4e00\u6b21\u63a5\u89e6\u539f\u751f ios native\uff0c\u8bf7\u6559\u5404\u4f4d\u3002<\/p>\n<p>\u5df2\u7ecf\u8fdb\u884c\u4e86\u7684\u64cd\u4f5c\uff1a<br \/> 1 \u3001apple \u5f00\u53d1\u8005\u8d26\u6237\u7f51\u9875\u6dfb\u52a0\u4e86 push notification \u8bc1\u4e66<br \/> 2 \u3001xcode \u91cc runner target \u7684 capability \u4e5f\u6253\u5f00\u4e86\u63a8\u9001<br \/> 3 \u3001\u5982\u4e0b\u4fee\u6539\u4e86 AppDelegate.swift \uff08\u53c2\u8003\u7684\u5b98\u65b9\u6587\u6863\uff09<\/p>\n<p>\u4f46\u662f\u771f\u673a\u6d4b\u8bd5\u5e76\u6ca1\u6709 print \u51fa token \u503c\uff0c\u5c31\u5f88\u7591\u60d1\uff0c\u60f3\u8bf7\u6559\u662f\u4e0d\u662f\u7f3a\u5c11\u4e86\u4ec0\u4e48\u6b65\u9aa4\uff0c\u8fd8\u662f AppDelegate.swift \u5199\u9519\u4e86<\/p>\n<pre><code>import UIKit import Flutter  @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate {     override func application(_ application: UIApplication,                                 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?     ) -&gt; Bool {         UIApplication.shared.registerForRemoteNotifications()         GeneratedPluginRegistrant.register(with: self)         return super.application(application, didFinishLaunchingWithOptions: launchOptions)     }          override func application(_ application: UIApplication,                                 didRegisterForRemoteNotificationsWithDeviceToken                                 deviceToken: Data) {         print(deviceToken)         sendDeviceTokenToServer(token: deviceToken)     } }  func sendDeviceTokenToServer(token: Data) {     let url = URL(string: \"https:\/\/push.example.com\/ios?token=\" + String(decoding: token, as: UTF8.self))!      let task = URLSession.shared.dataTask(with: url) {(data, response, error) in         guard let data = data else { return }         print(String(data: data, encoding: .utf8)!)     }      task.resume() } <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>1<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5736967\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : frqk <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6ca1\u6709 requestAuthorization \u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u6559\u4e0b iOS \u63a8\u9001 AppDel&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/427900"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=427900"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/427900\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=427900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=427900"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=427900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}