本文介绍了关于推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好先生,



我是Likesh。我在mvc web api中创建了web服务。在这里我使用pushsharp dll向苹果设备发送推送通知。

但是通知不是在设备上发送而代码没有给出任何错误。

这里我的代码 -

Hello Sir,

I am Likesh . I have created web service in mvc web api. and here i am sending push notification to apple device using pushsharp dll.
But notification is not sending on device and code is not giving any error .
Here my code-

public void SendPush(string deviceToken, string message, string baseurl)
{
    if (!string.IsNullOrEmpty(deviceToken))
    {
        var push = new PushBroker();
        //Wire up the events for all the services that the broker registers
        push.OnNotificationSent += NotificationSent;
        push.OnChannelException += ChannelException;
        push.OnServiceException += ServiceException;
        push.OnNotificationFailed += NotificationFailed;
        push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
        push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
        push.OnChannelCreated += ChannelCreated;
        push.OnChannelDestroyed += ChannelDestroyed;
        try
        {
            string ss = HostingEnvironment.MapPath(@"~\Resources\Certificates2.p12");
            var appleCert = File.ReadAllBytes(ss);
            push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, "123"));
            push.QueueNotification(new AppleNotification()
            .ForDeviceToken(deviceToken)//the recipient device id
            .WithAlert(message)//the message
            .WithBadge(5)
            .WithSound("snap audio alert.mp3")
                // .WithSound("default")
            );
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
}



谢谢

Likesh Puwar

likesh1989 @gmail.com


Thanks
Likesh Puwar
[email protected]

推荐答案


这篇关于关于推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 12:43