

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 管理 Amazon SNS 行動推播通知的最佳實務
<a name="mobile-push-notifications-best-practices"></a>

本節描述可能有助於您提升客戶參與度的最佳實務。

## 端點管理
<a name="channels-sms-best-practices-endpoint-management"></a>

交付問題可能發生在下列情況中：使用者因裝置上的動作 （例如，在裝置上重新安裝應用程式） 而變更裝置權杖，或[憑證更新](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_certificate-based_connection_to_apns)影響在特定 iOS 版本上執行的裝置。Apple 推薦的最佳實務是在您的應用程式每次啟動時[註冊](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/HandlingRemoteNotifications.html#:~:text=Registering%20to%20Receive%20Remote%20Notifications) APN。

由於裝置字符不會在每次使用者開啟應用程式時變更，因此可以使用等冪 [https://docs.aws.amazon.com/sns/latest/api/API_CreatePlatformEndpoint.html](https://docs.aws.amazon.com/sns/latest/api/API_CreatePlatformEndpoint.html) API。不過，如果字符本身無效，或者端點有效但已停用 （例如生產和沙盒環境不相符），這可能會為相同的裝置引入重複項目。

可以使用裝置字符管理機制，例如[虛擬程式碼](mobile-platform-endpoint.md#mobile-platform-endpoint-pseudo-code)。

如需管理和維護 FCM v1 裝置字符的資訊，請參閱 [Firebase Cloud Messaging 端點的 Amazon SNS 管理](sns-fcm-endpoint-management.md)。

## 交付狀態記錄
<a name="channels-sms-best-practices-delivery-logging"></a>

若要監控推送通知交付狀態，我們建議您為 Amazon SNS 平台應用程式啟用交付狀態記錄。這有助於您疑難排解交付失敗問題，因為日誌包含從推送平台服務傳回的提供者[回應代碼](sns-msg-status.md#platform-returncodes)。如需啟用交付狀態記錄的詳細資訊，請參閱[如何存取 Amazon SNS 主題交付日誌以取得推送通知？](https://aws.amazon.com/premiumsupport/knowledge-center/troubleshoot-failed-sns-deliveries/)。

## 事件通知
<a name="channels-sms-best-practices-event-notifications"></a>

若要以事件驅動的方式管理端點，您可以使用[事件通知](application-event-notifications.md#application-event-notifications-sdk)功能。這樣，設定的 Amazon SNS 主題就可以將事件擴散給訂閱者 (例如 Lambda 函數)，以處理端點建立、刪除、更新和交付失敗的平台應用程式事件。