Amazon SNSãapns-push-typeãããã¼ã«å¯¾å¿ããæ¨ãã¢ãã¦ã³ã¹ããã¾ãããã²ã¨ã¾ã解決ã§ãã
ãããã触ã£ã¦ã¿ããã§ããããªãã ãç¶æ³ãããè¦ããªãã®ã§ä¼ç¤¾ããã°ãQiitaã«æ¸ãããã«ãããããã²ã¨ã¾ãå人ããã°ã§ä¾é¤ãã¾ãã¿ãããªãã¤ã§ãã
- Motivation
- apns-push-typeåé¡ã®çµè«
- deviceTokenãæ£ããåããªãç½ ãè¸ãã
- phonegap-plugin-pushã«PRæãã¾ãã
- ã¾ã¨ã
Motivation
iOS 13ï¼ã¨watchOS 6ï¼ä»¥éã®ããã¤ã¹ã«å¯¾ãã¦ããã·ã¥éç¥ãéãå ´åã«ã追å ã®ãããã¼ãå¿ é ã«ãªãã¨ããæ å ±ããããã¥ã¡ã³ãã«è¿½è¨ããã¦ãã¾ããï¼2019å¹´8æ20æ¥ç¾å¨ï¼ã
Header field Description apns-push-type
(Required when delivering notifications to devices running iOS 13 and later, or watchOS 6 and later. Ignored on earlier system versions.) The type of the notification. The value of this header is alert or background. Specify alert when the delivery of your notification displays an alert, plays a sound, or badges your app's icon. Specify background for silent notifications that do not interact with the user.
The value of this header must accurately reflect the contents of your notification's payload. If there is a mismatch, or if the header is missing on required systems, APNs may delay the delivery of the notification or drop it altogether.
For information about configuring notification alerts, see Generating a Remote Notification. For more information about sending background notifications, see Pushing Background Updates to Your App.Sending Notification Requests to APNs | Apple Developer Documentation
è¦ç´ããã¨
apns-push-type
ãããã¼ã«alert
ãbackground
ãæå®ãã¦ãã ããalert
ãæå®ããã®ã¯ãã¦ã¼ã¶ã¼ã«éç¥ã®åå¨ãè¦ãããå ´åã§ãbackground
ãæå®ããã®ã¯ãã¦ã¼ã¶ã¼ã«ä½ãæ°ã¥ãããªãï¼ããã¯ã°ã©ã¦ã³ãããã»ã¹ãèµ·åããã®ã¿ã«çããï¼å ´åã§ã
ããã¾ã§åãåãå´ï¼iOSããã¤ã¹å´ï¼ã§æ¯ãåãã¦ãããã®ãããµã¼ãã¼å´ããå¶å¾¡ããæå³ãããããã§ãã
apns-push-typeãä»ä¸ããªãã¨ã©ããªãã®ã
APNsã«å¯¾ãã¦è¡ã£ãããã·ã¥éç¥ä¾é ¼ã®POSTãªã¯ã¨ã¹ãã«ã 400 InvalidPushType
ã¨ããã¨ã©ã¼ã¬ã¹ãã³ã¹ãè¿ãããã§ãï¼Table 5 Response error stringsããï¼ã
Amazon SNSã¨ã大ä¸å¤«ï¼
åä¸ã¦ã¼ã¶ã¼ã®è¤æ°ããã¤ã¹å®ããããã»ã°ã¡ã³ãã®ã¦ã¼ã¶ã¼ãªã©ãããç¨åº¦ã®ã¾ã¨ã¾ã£ãããã·ã¥éç¥ããAndroid/iOSã®ä¸¡æ¹ã«éãããå ´åãªã©ã«ãAmazon SNSã®Mobile Pushã¨ãã£ããããã·ã¥éç¥ã®ã©ããã¼çãªãµã¼ãã¹ã使ããã¨ãããã¨æãã¾ãã
ãããã®ãµã¼ãã¹ã¯ã apns-push-type
ãããã¼ãä»ä¸ãã¦ãããã®ã§ãããããã¾ããä»ä¸ããªãã£ãå ´åã®ã¨ã©ã¼ãã³ããªã³ã°ã¯ã©ãããã°ããã§ããããã
ææªã®ã±ã¼ã¹ã¨ãã¦iOS 13ãæ£å¼ãªãªã¼ã¹ãããç´å¾ãããã¦ã¼ã¶ã¼ã«ããã·ã¥éç¥ãå±ããªããªãæããããã¨æãããããã調ã¹ã¦ã¿ããã¨ã«ãã¾ããã
apns-push-typeåé¡ã®çµè«
2019å¹´8æç¾å¨ã®SANDBOXç°å¢ã«éã£ã¦ããã°ãAmazon SNSç±æ¥ã®ããã·ã¥éç¥ã¯iOS 13ããã¤ã¹ã«å±ãã¾ããã
ã¨ã©ã¼ãåºããã¨ã確èªãã¦Amazonã«ç´è«å¤ããã¤ããã ã£ãã®ã§ãã¡ãã£ã¨æåæãã§ãã
Amazonããã£ãã apns-push-type
ãä»ä¸ããæ¹ä¿®ãæ¸ã¾ãã¦ããã®ããAppleãã¾ã APNsãµã¼ãã¼ã«ããã¥ã¡ã³ãã®å
容ãé©ç¨ãã¦ããªãã®ãâ¦â¦å¾è
ã ã£ããæãããâ¦â¦
deviceTokenãæ£ããåããªãç½ ãè¸ãã
ããããã¯ä½è«ã§ãã
Cordova iOS製ã®ã¢ããªãiOS 13ããã¤ã¹ã«å
¥ãã¦æ¤è¨¼ãã¦ããã®ã§ãããåºç¤ã«APNsãã 400 BadDeviceToken
ã®ã¨ã©ã¼ãããã£ã¦ãã¾ãã¾ããã
Cordovaã§ããã·ã¥éç¥ãæ±ãå ´åã¯phonegap-plugin-pushã使ãã¾ããããã¤ã¹ç»é²ãè¡ã£ãéã® deviceToken
ãã16é²æ°æååã«å¤æãã¦ãã渡ãã¦ãããã®ã§ãã¡ãã£ã¨ä¾¿å©ã§ãã
ãã¦ã BadDeviceToken
ã¨ããããã«ã¯ deviceToken
ã«ãã¹ããã£ãã®ã ããã¨ãã°ãä»è¾¼ãã§ã¿ãã¨ã次ã®æååãåºã¦ãã¾ããã
"{length=32,bytes=0x3dd89c70dabd0be290cc2f8e215132e0...75a03b3cbf9bbe0a}"
ãããBase64ã¨ã³ã³ã¼ããããã®ã使ã£ã¦APNsã«ãªã¯ã¨ã¹ãããçµæã¨ãã¦ã BadDeviceToken
ãåºã¦ããããã§ãããããããªãã
ãã¦ã bytes
ã®ä¸èº«ã¯16é²æ°ã£ã½ãã§ãããè¬ã®çç¥ãããã¦ãã¾ããæ£è¦è¡¨ç¾ã§æãåºãã¨ãããã¨ãã§ããªãããã§ããObjective-Cå´ã®æåãå¤ãã£ãããã§ãJavaScriptå´ããã¯ã©ãã«ãã§ããªãããã§ãã
å®è£ ä¸ã®æå³ããã¦ããæå
phonegap-plugin-pushã®ã³ã¼ããèªãã§ã¿ãã¨ãNSDataåã® deviceToken
ãã description
ã§æååãåãåºããå¾ãå å·¥ãããã¨ã§16é²æ°æååãä½ã£ã¦ããããã§ããã
NSString *token = [[[[deviceToken description] stringByReplacingOccurrencesOfString:@"<"withString:@""] stringByReplacingOccurrencesOfString:@">" withString:@""] stringByReplacingOccurrencesOfString: @" " withString: @""];
https://github.com/phonegap/phonegap-plugin-push/blob/110e3c2/src/ios/PushPlugin.m#L365
ä¸è¨ã®å¦çã§ã¯ã[deviceToken description]
ã®çµæã次ã®ãããªæååã«ãªããã¨ãæå¾
ãã¦ãã¾ãã
<124686a5 556a72ca d808f572 00c323b9 3eff9285 92445590 3225757d b83997ba>
ã»ã¼ãã¤ããªã®16é²æ°è¡¨è¨ã§ããããããå å·¥ãããã¨ã§ãNSString *token
ã«ã¯ 124686a5556a72cad808f57200c323b93eff9285924455903225757db83997ba
ã¨ããæååãæ ¼ç´ããã¦ããããã§ãã
ããããªã {length=32,bytes=...}
ã«ãªã£ã¦ãã¾ã£ãã®ã§ããããã
NSData#descriptionã®æåãå¤ãã£ãï¼
Appleã®ãã©ã¼ã©ã ã調ã¹ã¦ã¿ãã¨ãä¼¼ããããªè©±é¡ãè¦ã¤ããã¾ããã
- iOS13 PKPushCredentials broken |Apple Developer Forums
- NSData description and NSString stringWithForma... |Apple Developer Forums
ããã·ã¥éç¥ã deviceToken
ãã©ãã®ããã®ã¨ããããã¯ã description
ã®æåãã®ãã®ãå¤ãã£ã¦ãã¾ã£ããããªå°è±¡ãåãã¾ãããã©ããªãã§ãããâ¦â¦â¦
phonegap-plugin-pushã«PRæãã¾ãã
ã²ã¨ã¾ãç®ã®åã®åé¡ã¨ãã¦ãphonegap-plugin-pushãä½ã¨ãããªãã¨ãããªãã®ã§ãiOS 13以éã§ã¯ description
ã使ããã« deviceToken
ã®16é²æ°æååãçæã§ããããã«ããPRãä½æãã¾ããã
ãã©ã¼ã©ã ã§FBã®å®è£ ããããï¼ã¨ããæ¸ãè¾¼ã¿ããã£ãã®ã§ãã»ã¼ã³ããã§ãã
Objective-Cã§OSSã«PRãæããå®ç¸¾ã解é¤ãããï¼ï¼ï¼ð ï¼ã¾ã ãã¼ã¸ãããããã§ã¯ãªãï¼
ãã¼ã¸ããã¾ãã
ã¤ã¨ã¼ã¤âï¸âï¸âï¸âï¸âï¸âï¸âï¸âï¸âï¸âï¸
Ionicã§ãããã·ã¥éç¥ãããªãphonegap-plugin-push使ãã¨è¨ããã¦ãã®ã§ãããªãåºãç¯å²ã®äººã ãææ¸ã§ããã®ã§ã¯ãªãã ãããâ¦â¦
ã¾ã¨ã
iOS 13ã§ããã·ã¥éç¥ãåããªããªããããªç½ ãè¤æ°è¦ã¤ãã¦ãã¾ã£ã¦ãæ°ãæ°ã§ãªãã§ããâ¦â¦
ã©ããç©ä¾¿ã«æ£å¼ãªãªã¼ã¹ã®æ¥ãè¿ãããâ¦â¦