{"id":2004,"date":"2021-03-05T23:07:40","date_gmt":"2021-03-05T15:07:40","guid":{"rendered":"http:\/\/123.57.164.21\/?p=2004"},"modified":"2021-04-16T13:14:27","modified_gmt":"2021-04-16T05:14:27","slug":"ios-%e8%bf%9c%e7%a8%8b%e9%80%9a%e7%9f%a5%e7%9a%84%e4%b8%80%e4%ba%9btips","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=2004","title":{"rendered":"IOS \u8fdc\u7a0b\u901a\u77e5\u7684\u4e00\u4e9bTips"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">\u6253\u5f00 \u300cPush Notifications\u300dCapability<\/h4>\n\n\n\n<p>\u9700\u8981\u6709\u5f00\u53d1\u8005\u8d26\u53f7\u624d\u80fd\u4f7f\u7528\u8fd9\u4e2aCapability<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"573\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/03\/image-18-1024x573.png\" alt=\"\" class=\"wp-image-2005\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-18-1024x573.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-18-300x168.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-18-768x430.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-18-830x464.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-18-230x129.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-18-350x196.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-18-480x269.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-18.png 1244w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">\u5728AppDelegate.swift\u4e2d\u7533\u8bf7\u901a\u77e5\u6743\u9650\uff0c\u5e76\u4e14\u5f97\u5230Apns ID<\/h4>\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=\"\">import UIKit\n\n@main\nclass AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {\n\n    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {\n        \/\/ Override point for customization after application launch.\n        UNUserNotificationCenter.current().delegate = self\n        \n        print(UIDevice.current.identifierForVendor!.uuidString)\n        \/\/ \u901a\u77e5\u6a29\u9650\u53d6\u5f97\n        UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) {\n            granted, error in\n            if granted {\n                \/\/\u8bb8\u53ef\u901a\u77e5\u4ee5\u540e\uff0c \u4f1a\u4ece\u82f9\u679c\u7684apns\u670d\u52a1\u5668,\u7533\u8bf7apns_id \n                DispatchQueue.main.async(execute: {\n                    UIApplication.shared.registerForRemoteNotifications()\n                })\n            }\n        }\n        \n        return true\n    }\n\n    \/\/ MARK: UISceneSession Lifecycle\n\n    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {\n        \/\/ Called when a new scene session is being created.\n        \/\/ Use this method to select a configuration to create the new scene with.\n        return UISceneConfiguration(name: \"Default Configuration\", sessionRole: connectingSceneSession.role)\n    }\n\n    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set&lt;UISceneSession>) {\n        \/\/ Called when the user discards a scene session.\n        \/\/ If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.\n        \/\/ Use this method to release any resources that were specific to the discarded scenes, as they will not return.\n    }\n    \n    \/\/ apns_id\u7533\u8bf7\u6210\u529f\u4f1a\u8fdb\u5165\u8fd9\u4e2a\u65b9\u6cd5\u3002\n    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\n           \n         let uuid = UIDevice.current.identifierForVendor!.uuidString\n         let deviceName = UIDevice.current.name\n         \n        \/\/ \u628a\u53d6\u5f97\u7684Apns_Id \u548c uuid mapping\u5728\u4e00\u8d77\u63d2\u5165\u5230\u6570\u636e\u5e93\u4e2d\u4fdd\u5b58\u3002\n        HttpService.insertApnsTable(uuid: uuid, deviceName: deviceName, apnsId: deviceToken.hexString){\n            let _: [String:Any] = $0\n        }\n       }\n    \n    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {\n        print(error.localizedDescription)\n    }\n    func userNotificationCenter(_ center: UNUserNotificationCenter,\n                                willPresent notification: UNNotification,\n                                withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)\n    {\n        completionHandler([.badge, .sound, .banner])\n    }\n    \n    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {\n        completionHandler()\n    }\n}\n\nextension Data {\n    var hexString: String {\n        let hexString = map { String(format: \"%02.2hhx\", $0) }.joined()\n        return hexString\n    }\n}<\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">\u6d88\u606f\u63a8\u9001\u6d4b\u8bd5\u53ef\u4ee5\u7528Knuff<\/h4>\n\n\n\n<p><a href=\"https:\/\/github.com\/KnuffApp\/Knuff\">https:\/\/github.com\/KnuffApp\/Knuff<\/a><\/p>\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\/2021\/03\/image-19-1024x929.png\" alt=\"\" class=\"wp-image-2008\" width=\"430\" height=\"390\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-19-1024x929.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-19-300x272.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-19-768x697.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-19-830x753.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-19-230x209.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-19-350x318.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-19-480x436.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-19.png 1040w\" sizes=\"(max-width: 430px) 100vw, 430px\" \/><\/figure><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e5f\u53ef\u4ee5\u7528nodejs \u4ee3\u7801\u63a8\u9001\u901a\u77e5<\/h4>\n\n\n\n<p>Nodejs\u53d1\u9001remote\u901a\u77e5\uff0c\u4e3b\u8981\u7528<strong>apn<\/strong>\u6a21\u5757\u3002npm install apn\u5373\u53ef\u4f7f\u7528\u3002<\/p>\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=\"\">const apn = require(\"apn\");\n\/\/ \u91cd\u8981\uff0c\u5426\u5219\u4f1a\u51fa\u8b66\u544a\n\/\/ MaxListenersExceededWarning: Possible EventEmitter memory leak detected\nrequire('events').EventEmitter.prototype._maxListeners = 100;\n\nvar options = {\n  \/\/ \u91cd\u8981\u63a8\u9001\u8bc1\u4e66\u5fc5\u987b\u7684p12\u6587\u4ef6\n  pfx: \".\/xxx\/apns.p12\",\n  \/\/ p12\u6587\u4ef6\u7684\u5bc6\u7801\n  passphrase: \"password\",\n  production: true,\n  \/\/ \u91cd\u8981\uff01\uff01\uff01 \u4e0d\u52a0\u8fd9\u53e5\u8bdd \u6709\u65f6\u5019\u4f1a\u51fa\u9519\u3002\n  rejectUnauthorized: false\n};\n\nvar apnProvider = new apn.Provider(options);\n\nfunction sendMessage(deviceToken, uuid) {\n \n  console.log(\"sendMessage\")\n  let notification = new apn.Notification();\n  \/\/\/ Convenience setter\n  notification.title = \"Hello World\";\n  notification.body = \"\";\n  notification.badge = 1;\n  \/\/ \u91cd\u8981\u5fc5\u987b\u548capp\u7684Bundle identifier\u80fdmatch\u4e0a\u3002\n  notification.topic = \"com.cn.test\";\n  notification.sound = \"default\";\n  \/\/ \u975e\u5e38\u91cd\u8981\uff0c \u5bf9\u5e94 PushNotificationPayload.apns\u7684category\uff0c \u53ea\u6709\u8bbe\u5b9a\u624d\u80fd\u663e\u793a\u81ea\u5b9a\u4e49\u901a\u77e5\u89c6\u56fe\u3002\n  notification.category = \"myCategory\";\n  notification.launchImage = uuid;\n  \n  \/\/ \u8fd9\u91cc\u7684deviceToken\u5c31\u662f\u82f9\u679c\u7684apns_ID\n  apnProvider.send(notification, deviceToken).then((result) => {\n    console.log(result.failed)\n  });\n}\n\nmodule.exports = {\n  sendMessage\n}<\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">\u53e6\u5916\uff0cAppleWatch\u53ef\u4ee5\u81ea\u5b9a\u4e49\u901a\u77e5\u754c\u9762\uff0c\u6ce8\u610f\u70b9\u5982\u4e0b<\/h4>\n\n\n\n<ul><li>\u6ce8\u610f PushNotificationPayload.apns\u6587\u4ef6\u3002category\u5f88\u91cd\u8981\uff0c\u53d1\u9001remote\u901a\u77e5\u65f6\uff0c\u9700\u8981\u6307\u5b9acategory\u7684\u540d\u5b57\uff0c\u8fd9\u6837\u624d\u80fd\u663e\u793a\u51fa\u6765\u81ea\u5b9a\u4e49\u7684\u901a\u77e5\u3002<\/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\/2021\/03\/image-20-1024x648.png\" alt=\"\" class=\"wp-image-2012\" width=\"461\" height=\"292\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-20-1024x648.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-20-300x190.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-20-768x486.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-20-1536x972.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-20-830x525.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-20-230x146.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-20-350x222.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-20-480x304.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-20.png 1558w\" sizes=\"(max-width: 461px) 100vw, 461px\" \/><\/figure><\/div>\n\n\n\n<ul><li>NotificationController.swift\u7c7b\uff0c\u6536\u5230\u901a\u77e5\u65f6\uff0c\u4f1a\u9996\u5148\u8c03\u7528NotificationController\uff0c\u5728\u8be5\u7c7bdidReceive\u65b9\u6cd5\u4e2d\u80fd\u6536\u5230\u901a\u77e5\u7684\u503c\u3002<\/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\/2021\/03\/image-21-488x1024.png\" alt=\"\" class=\"wp-image-2013\" width=\"330\" height=\"692\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-21-488x1024.png 488w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-21-143x300.png 143w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-21-230x482.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-21-350x734.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-21-480x1006.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-21.png 582w\" sizes=\"(max-width: 330px) 100vw, 330px\" \/><\/figure><\/div>\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=\"\">import WatchKit\nimport SwiftUI\nimport UserNotifications\nimport Starscream\n\n\/\/ \u5728AppleWatch\u4e2d\u4e5f\u53ef\u4ee5\u8fde\u63a5WebSocket\nclass NotificationController: WKUserNotificationHostingController&lt;NotificationView>, WebSocketDelegate {\n    \n    var uuid:String = \"\"\n    override var body: NotificationView {\n        return NotificationView(uuid: uuid)\n    }\n    \n    override func willActivate() {\n        \/\/ This method is called when watch view controller is about to be visible to user\n        super.willActivate()\n        notificationController = self\n    }\n    \n    override func didDeactivate() {\n        \/\/ This method is called when watch view controller is no longer visible\n        super.didDeactivate()\n    \n    }\n    \/\/ \u6d88\u606f\u9001\u6765\u65f6\uff0c \u4f1a\u6fc0\u6d3b\u8fd9\u4e2a\u65b9\u6cd5\uff0c \u53ef\u4ee5\u4ecenotification\u4e2d\u53d6\u5f97\u6d88\u606f\u4e2d\u7684\u4e00\u4e9b\u503c\uff0c \u5e76\u628a\u503c\u4f20\u7ed9NotificationView\n    override func didReceive(_ notification: UNNotification) {\n        \/\/\u8fd9\u91cc\u6536\u5230\u901a\u77e5\u53d1\u8fc7\u6765\u7684uuid \n        uuid = notification.request.content.launchImageName\n        \/\/ This method is called when a notification needs to be presented.\n        \/\/ Implement it if you use a dynamic notification interface.\n        \/\/ Populate your dynamic notification interface as quickly as possible.\n\n        \u91cd\u8981\uff1a\u6d88\u606f\u663e\u793a5\u79d2\u540e\uff0c\u81ea\u52a8\u5173\u95ed\n        DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(5)) {\n            self.performDismissAction()\n        }\n    }\n    \n    func didReceive(event: WebSocketEvent, client: WebSocket) {\n        switch event {\n        case .connected(_):\n            break\n        case .disconnected(_,_):\n            break\n        case .text(_):\n            break\n        case .binary(_):\n            break\n        case .ping(_):\n            break\n        case .pong(_):\n            break\n        case .reconnectSuggested(_):\n            break\n        case .error(_):\n            break\n    }\n}\n\nextension Notification.Name {\n    static var connected: Notification.Name {\n        Notification.Name(\"connected\")\n    }\n}<\/pre>\n\n\n\n<ul><li>NotificationView\u7c7b\uff0c\u8fd9\u4e2a\u7c7b\u5c31\u662f\u901a\u77e5\u7684\u89c6\u56feView\u4e86\uff0c\u4f8b\u5b50\u4e2d\u662fSwiftUI\u753b\u7684\u3002<\/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\/2021\/03\/image-22.png\" alt=\"\" class=\"wp-image-2016\" width=\"323\" height=\"633\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-22.png 520w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-22-153x300.png 153w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-22-230x451.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-22-350x687.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-22-480x942.png 480w\" sizes=\"(max-width: 323px) 100vw, 323px\" \/><\/figure><\/div>\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=\"\">import SwiftUI\nimport Starscream\n\nvar socket: WebSocket?\nvar request: URLRequest?\nvar notificationController: NotificationController?\n\nstruct NotificationView: View {\n    \/\/ \u4eceNotificationController.swift\u4f20\u8fc7\u6765\u7684\u503c\n    @State var uuid:String\n    var body: some View {\n            VStack(spacing: 0) {\n                VStack{\n                    HStack {\n                        Text(self.uuid)\n                        Spacer()\n                    }\n                    Spacer()\n                }.frame(width: 160, height: 65)\n                \n                Spacer().frame(height: 8)\n                \n                \/\/ \u901a\u77e5\u89c6\u56fe\u91cc\u9762\u4e5f\u53ef\u4ee5\u8fde\u63a5websocket\u670d\u52a1\u5668\u3002\n                Button(action: {\n                    request = URLRequest(url: URL(string: \"ws:\/\/localhost:6003\")!)\n                    request!.setValue(\"xxxxxxxx\", forHTTPHeaderField: \"apikey\")\n                    request!.setValue(self.uuid, forHTTPHeaderField: \"uuid\")\n                    request!.timeoutInterval = 5\n                    socket = WebSocket(request: request!)\n                    socket!.delegate = notificationController\n                    socket!.connect()\n                })\n                {\n                    Text(\"connect WebSocket Server\")\n                }\n                .frame(width: 155)\n            }\n        }\n    }<\/pre>\n\n\n\n<ul><li>\u53e6\u5916\u5728ios\u4e2d websocket\u4e3b\u8981\u7528Starscream\u7b2c\u4e09\u65b9\u5e93\u3002\u4e0b\u9762\u662fStarscream pod\u6587\u4ef6\u3002<\/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=\"\"># Uncomment the next line to define a global platform for your project\n# platform :ios, '9.0'\n\ntarget 'AppleWatchDemo' do\n  # Comment the next line if you don't want to use dynamic frameworks\n  use_frameworks!\n\n  # Pods for AppleWatchDemo\n\nend\n\ntarget 'AppleWatchDemo WatchKit App' do\n  # Comment the next line if you don't want to use dynamic frameworks\n  use_frameworks!\n\n  # Pods for AppleWatchDemo WatchKit App\n\nend\n\ntarget 'AppleWatchDemo WatchKit Extension' do\n  # Comment the next line if you don't want to use dynamic frameworks\n  use_frameworks!\n  pod 'Starscream'\n\n  # Pods for AppleWatchDemo WatchKit Extension\n\nend\n<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u8fdc\u7a0b\u901a\u77e5\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u901a\u77e5\u58f0\u97f3<\/h4>\n\n\n\n<ul><li>\u5236\u4f5c\u5b8c\u6587\u4ef6\u540e\uff0c\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u5c06\u5176\u653e\u5165\u5e94\u7528\u7a0b\u5e8f\u6346\u7ed1\u5305\u4e2d\u3002\u5c31\u662f\u628a\u81ea\u5b9a\u4e49\u7684\u58f0\u97f3\u6587\u4ef6\u62d6\u62fd\u5230\u5de5\u7a0b\u91cc\u9762\uff08Copy items if needed\uff09<\/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\/2021\/04\/image-77-1024x556.png\" alt=\"\" class=\"wp-image-2366\" width=\"639\" height=\"347\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/04\/image-77-1024x556.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/04\/image-77-300x163.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/04\/image-77-768x417.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/04\/image-77-1536x833.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/04\/image-77-2048x1111.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2021\/04\/image-77-830x450.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/04\/image-77-230x125.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/04\/image-77-350x190.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/04\/image-77-480x260.png 480w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/figure><\/div>\n\n\n\n<ul><li>\u5728Nodejs\u4ee3\u7801\u4e2d\u6307\u5b9a\u58f0\u97f3\u6587\u4ef6\u7684\u540d\u5b57\u5c31\u53ef\u4ee5\u4e86\u3002<\/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=\"\">let notification = new apn.Notification();\n  notification.title = \"XXXXX\";\n  notification.body = message;\n  notification.badge = 0;\n  notification.topic = \"XXXXXX\";\n  \/\/ \u203b\u8fd9\u91cc\u6307\u5b9a\u58f0\u97f3\u6587\u4ef6\u7684\u540d\u5b57\n  notification.sound = \"ABC.m4a\";\n  \/\/ notification.category = \"myCategory\";<\/pre>\n\n\n\n<ul><li>\u6ce8\u610f\uff1a\u97f3\u9891\u6587\u4ef6\u7684\u7c7b\u578b wav\uff0c ma4\uff0c caf\u3002\u81ea\u5b9a\u4e49\u58f0\u97f3\u5728\u64ad\u653e\u65f6\u5fc5\u987b\u572830\u79d2\u4ee5\u5185\u3002\u5982\u679c\u81ea\u5b9a\u4e49\u58f0\u97f3\u8d85\u8fc7\u8be5\u9650\u5236\uff0c\u5219\u4f1a\u64ad\u653e\u9ed8\u8ba4\u7684\u7cfb\u7edf\u58f0\u97f3\u3002<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6253\u5f00 \u300cPush Notifications\u300dCapability \u9700\u8981\u6709\u5f00\u53d1\u8005\u8d26\u53f7\u624d\u80fd\u4f7f\u7528\u8fd9\u4e2aCapabil [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,8],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/2004"}],"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=2004"}],"version-history":[{"count":16,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/2004\/revisions"}],"predecessor-version":[{"id":2367,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/2004\/revisions\/2367"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2004"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2004"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2004"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}