为什么我的计划Azure通知无法通过电话到达最终用户?

fdx2calv  于 2023-06-30  发布在  其他
关注(0)|答案(1)|浏览(109)

我在使用Azure通知中心获取到达手机的计划通知时遇到问题。要明确的是,我支付的标准价格轮胎,使调度通知。
当我使用通知中心ScheduleNotificationAsync()的预定义方法时,我可以在Azure指标中的“已发送的计划通知”中看到它,但它不会到达实际手机上的最终用户。
代码:

var notification = new AppleNotification(payload, headers);

        DateTimeOffset currentTime = DateTimeOffset.UtcNow.ToOffset(new TimeSpan(2, 0, 0));

        // Calculate the scheduled time by adding the desired delay (e.g., 1 minute)
        DateTimeOffset scheduledTime = currentTime.AddSeconds(10);

        // Convert the scheduled time back to UTC before scheduling the notification
        DateTimeOffset scheduledTimeUtc = scheduledTime.ToUniversalTime();

        var scheduledNotification = await _pushNotificationsHub.ScheduleNotificationAsync(notification, scheduledTimeUtc, deviceHandle);

当我使用方法SendDirectNotification()时,它工作得非常好,它到达了最终用户。

xpcnnkqh

xpcnnkqh1#

我有MSDOCgit for Azure Notification Hub和Thank for commits@brads3290.

var hubClient = NotificationHubClient.CreateClientFromConnectionString(connectionString, hubName);
    var notification = new AppleNotification("Your notification payload");
     DateTimeOffset currentTime =     DateTimeOffset.UtcNow.ToOffset(new TimeSpan(2, 0, 0));
     DateTimeOffset scheduledTime = currentTime.AddSeconds(10);
     DateTimeOffset scheduledTimeUtc = scheduledTime.ToUniversalTime();
       var deviceHandle = "device_handle"; 
        try
            {
                var result = await hubClient.ScheduleNotificationAsync(notification, scheduledTimeUtc, deviceHandle);
                Console.WriteLine("Scheduled notification successfully.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error scheduling notification: " + ex.Message);
            }
        }
    }
}

设备注册:

相关问题