移动消息推送库 PushSharp

本文介绍了PushSharp库的使用方法,该库支持iOS、Android、Windows Phone和Windows 8设备的消息推送。文中提供了示例代码,展示了如何为iOS和Android设备配置推送服务并发送消息。
摘要由CSDN通过智能技术生成

PushSharp 实现了服务器端向移动客户端推送消息的库,支持 iOS (iPhone/iPad APNS), Android (C2DM and GCM - Google Cloud Message), Windows Phone, 和  Windows 8 devices!

示例代码:

01//Create our push services broker
02var push = new PushBroker();
03 
04//Registering the Apple Service and sending an iOS Notification
05var appleCert = File.ReadAllBytes("ApnsSandboxCert.p12"));
06push.RegisterAppleService(new ApplePushChannelSettings(appleCert, "pwd"));
07push.QueueNotification(new AppleNotification()
08                           .ForDeviceToken("DEVICE TOKEN HERE")
09                           .WithAlert("Hello World!")
10                           .WithBadge(7)
11                           .WithSound("sound.caf"));
12 
13 
14//Registering the GCM Service and sending an Android Notification
15push.RegisterGcmService(new GcmPushChannelSettings("theauthorizationtokenhere"));
16//Fluent construction of an Android GCM Notification
17//IMPORTANT: For Android you MUST use your own RegistrationId here that gets generated within your Android app itself!
18push.QueueNotification(new GcmNotification().ForDeviceRegistrationId("DEVICE REGISTRATION ID HERE")
19                      .WithJson("{\"alert\":\"Hello World!\",\"badge\":7,\"sound\":\"sound.

转载于:https://www.cnblogs.com/kuaidianba/archive/2013/03/29/2989151.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值