C# PushSharp 推送報 APNS NotificationFailureException -> 8 : Invalid token,Token 64 位十六進制字符串。
.ForDeviceToken() 接受十六進制字符串會自動轉換,**不要手動截取/轉換**。push.RegisterAppleService(settings, false) (isSandbox=true)。isSandbox=false。production_identity.p12 是生產證書,密碼正確。openssl pkcs12 -in production_identity.p12 -nodes -out cert.pem 導出證書檢查 Subject/CN。push.QueueNotification(new AppleNotification().ForDeviceToken(token).WithAlert("test")); 觀察詳細錯誤碼。
// 正確註冊生產環境服務
push.RegisterAppleService(new ApplePushChannelSettings(appleCert, keyWord, false)); // false = 生產環境
// Token 直接傳入原始 64 位十六進制字符串
push.QueueNotification(new AppleNotification()
.ForDeviceToken(token) // 不要截取/轉換
.WithAlert(message));
**核心:Token 原樣傳入,證書環境與 Token 環境嚴格對應,Bundle ID 一致。**