1

Android アプリケーションをダウンロードしたすべての Android デバイスに、.Net サーバーから通知を送信しようとしています。PushSharp ライブラリを使用しています。通知の送信は問題ありません。しかし、ユーザーがアプリケーションをアンインストールしてからダウンロードした場合、正規の登録 ID を教えてくれる GCM からの応答を取得しようとしています。同じ Android デバイスに牽引通知を送信する際に問題が発生しています。1 つは新しい ID を使用し、もう 1 つは未登録の ID を使用して、その ID をデータベースから削除しようとしています。1 つのデバイスに対して 1 つの通知のみを送信できるようにします。GCM によってトリガーされるこれら 4 つのイベントを登録します。どのイベントでロジックを実行できますか?

どんな助けでも大歓迎です。

これが私のコードです:

    private static void Events_OnNotificationSent(Notification notification)
    {

    }

    private static void Events_OnNotificationSendFailure(Notification notification, Exception notificationFailureException)
    {

    } 



    private static void Events_OnChannelException(Exception exception, PlatformType platformType, Notification notification)
    {
    } 



    private static void Events_OnDeviceSubscriptionExpired(PlatformType platform, string deviceInfo, Notification notification)
    {

    } 



    private static void Events_OnDeviceSubscriptionIdChanged(PlatformType platform, string oldDeviceInfo, string newDeviceInfo, Notification notification)
    {

    }
4

1 に答える 1

0

ユーザーがアプリをアンインストールした場合、データベースからデバイスを削除することをお勧めします。私は自分のプロジェクトでそれを行うために次のロジックを使用しています:

private void Events_OnNotificationFailed(object sender, INotification notification, Exception error)
{
    var gcmNotification = notification as GcmNotification;
    bool userHasUninstalled = error.Message.Contains("Device Subscription has Expired");
    bool isAndroidNotification = gcmNotification != null;
    if (isAndroidNotification && userHasUninstalled)
    {
        foreach (var registrationId in gcmNotification.RegistrationIds)
        {
            DeleteDeviceByIdentifier(registrationId);
        }
    }
}
于 2013-09-07T19:29:38.447 に答える