< back

Service内网推送 实现推送+回调处理

问题

点击推送的时可以弹出窗口问题: 内网推送如何实现点击推送消息后接收回调信息

解决

在MobileGlobal中添加以下代码

内网推送回调接收,回调是发给发送方的,会提供接收方设备id,如果需要接收设备显示内容,参考以下代码:static Smobiler.Service.Push.PushClient pushClient = new Smobiler.Service.Push.PushClient("应用id");

static MobileGlobal()
{
    pushClient.ClientCallBack += PushClient_ClientCallBack;
}

private static void PushClient_ClientCallBack(object sender, Smobiler.Service.Push.PushClientCallBackEventArgs e)
{
    //此处回调是点击通知栏时接收的信息,可以自行修改为需要的内容
    ClientVariables cc = ClientVariables.GetCurrentClient(e.DeviceID);
    cc.GetActiveForm().MessageBox.Show(e.Param);
    cc.RenderFlush();
}

public static void sendmessage(string title, string msg, string param, params string[] devices)
{
    pushClient.PushClientCallBack(title, msg, param, devices);
}

使用代码创建通知, 440000000048726 为设备编号 this.client.DeviceID

cc.GetActiveForm().MessageBox.Show("");

cc.RenderFlush();MobileGlobal.sendmessage("标题", "这里是通知消息的内容", "这里是回调接收的数据", new string[] { "440000000048726" });