Mih*_*sca 2 push-notification xamarin.android
有没有人使用Push Sharp(https://github.com/Redth/PushSharp)在monodroid应用程序中实现推送通知?
我想使用这个解决方案,但我还没有能够运行测试.
任何人都可以提出如何做到这一点的教程吗?
谢谢
我是PushSharp的作者.
GCM运行良好,很容易启动和运行!
要设置Google API的项目,您可以按照以下指南操作:https: //github.com/Redth/PushSharp/wiki/How-to-Configure-&-Send-GCM-Google-Cloud-Messaging-Push-Notifications-using -PushSharp
正如@SpiritMachine所提到的,您可以将Mono For Android应用程序的客户端示例使用.简单地采用项目并根据自己的喜好进行调整可能是最简单的(如上所述). https://github.com/Redth/PushSharp/tree/master/Client.Samples/PushSharp.ClientSample.MonoForAndroid/PushSharp.ClientSample.MonoForAndroid.Gcm
最后,从服务器使用PushSharp发送GCM通知非常简单:
//Create a new instance of PushService
PushService push = new PushService();
//Configure and start Android GCM
//IMPORTANT: The SENDER_ID is your Google API Console App Project ID.
// Be sure to get the right Project ID from your Google APIs Console.
// It's not the named project ID that appears in the Overview,
// but instead the numeric project id in the url:
// eg: https://code.google.com/apis/console/?pli=1#project:785671162406:overview
// where 785671162406 is the project id, which is the SENDER_ID to use!
push.StartGoogleCloudMessagingPushService(
new GcmPushChannelSettings("785671162406", "AIzaSyC2PZNXQDVaUpZGmtsF_Vp8tHtIABVjazI", "com.pushsharp.test"));
//Fluent construction of an Android GCM Notification
//IMPORTANT: For Android you MUST use your own RegistrationId here
// that gets generated within your Android app itself!
push.QueueNotification(NotificationFactory.AndroidGcm()
.ForDeviceRegistrationId("<YOUR_REGISTRATION_ID_HERE>")
.WithCollapseKey("NONE")
.WithJson("{\"alert\":\"Alert Text!\",\"badge\":\"7\"}"));
//Stop the server if you have nothing else to send for a long time
// and tell it to process the remaining queue before exiting!
push.StopAllServices(true);
Run Code Online (Sandbox Code Playgroud)
当然,PushSharp也可以在NuGet上使用.
祝好运!
| 归档时间: |
|
| 查看次数: |
3941 次 |
| 最近记录: |