Push notification 单机器人与pushsharp

Push notification 单机器人与pushsharp,push-notification,xamarin.android,Push Notification,Xamarin.android,是否有人使用push Sharp()在monodroid应用程序中实现了推送通知 我想使用这个解决方案,但我还不能运行测试 有人能提供一个关于如何做到这一点的教程吗 谢谢GCM在安卓系统上确实运行良好 PushSharp服务器应用程序似乎在多个移动操作系统实现中提供了一些非常好的功能和管理 但是,如果您真的希望只使用更简单的功能访问GCMAPI,那么您可以相当快地启动并运行它 我使用Ruby编写了自己的裸体服务器。它是一个Sinatra应用程序,只允许设备注册/注销,并提供HTTP URL来发布

是否有人使用push Sharp()在monodroid应用程序中实现了推送通知

我想使用这个解决方案,但我还不能运行测试

有人能提供一个关于如何做到这一点的教程吗


谢谢

GCM在安卓系统上确实运行良好

PushSharp服务器应用程序似乎在多个移动操作系统实现中提供了一些非常好的功能和管理

但是,如果您真的希望只使用更简单的功能访问GCMAPI,那么您可以相当快地启动并运行它

我使用Ruby编写了自己的裸体服务器。它是一个Sinatra应用程序,只允许设备注册/注销,并提供HTTP URL来发布消息。我用了大约30分钟。别开玩笑了。它在Heroku上运行

然后,我从PushSharp存储库中获取MonoDroid客户端示例,对其进行定制,以使用我的API注册/注销,并对其进行了调整以满足我的需要


不过,首先,您需要使用GoogleAPI创建一个项目,并为此启用GCM。你可以从那开始。

我是《普什夏普》的作者

GCM运行得非常好,并且非常容易启动和运行

要设置Google API的项目,您可以遵循以下指南:

正如@SpiritMachine所提到的,您可以使用Mono for Android应用程序的客户端示例。这可能是最简单的(如前所述)简单地采取该项目,并调整到您喜欢的。

最后,使用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);
//创建PushService的新实例
PushService push=新的PushService();
//配置并启动Android GCM
//重要提示:发件人ID是您的Google API控制台应用程序项目ID。
//确保从GoogleAPI控制台获得正确的项目ID。
//概述中显示的不是命名的项目ID,
//而是url中的数字项目id:
//例如:https://code.google.com/apis/console/?pli=1#project:785671162406:overview
//其中785671162406是项目id,它是要使用的发送方id!
push.StartGoogleCloudMessagingPushService(
新的GcmPushChannelSettings(“785671162406”、“aizasyp2pznxqdvaupzgmtsf_Vp8tHtIABVjazI”、“com.pushsharp.test”);
//流畅地构建Android GCM通知
//重要提示:对于Android,您必须在此处使用自己的注册ID
//这在你的Android应用程序中生成!
push.QueueNotification(NotificationFactory.AndroidGcm()
.ForDeviceRegistrationId(“”)
.使用CollapseKey(“无”)
.WithJson(“{\”警报\“:\”警报文本!\”,“\”徽章\“:\”7\”);
//如果长时间没有其他东西要发送,请停止服务器
//并告诉它在退出之前处理剩余的队列!
push.StopAllServices(true);
当然,NuGet上也提供PushSharp


祝你好运

@SpiritMachine:谢谢你的链接!!我可能会有机会提供……谢谢你的回答:)我已经启动了Push Sharp项目。我还需要对iPhone推送通知的支持,所以我想我会选择推送方式谢谢你的回答。我设法让它跑了。非常干净,易于使用。伟大的解决方案:)如果你正在寻找一个已经发布的应用程序的“应用程序ID包名”(我被要求修改一个),转到Play Store的应用程序页面,它将出现在URL中(ID=…)