推送通知不会收到我的Android应用程序。我尝试了很多提供商,但我仍然无法让它工作。 没有,因为我的后端是在Asp.net我想使用Azure push hub,我不知道从哪里开始。并且我也有推送通知的一些经验。例如,我将如何发送像“检查更新”这样的简单推送。Asp.net推送通知
-2
A
回答
0
@Amr Alaa:你可以去蔚蓝色的通知中心。它有非常简单的实现。
你可以创建azure.by要新建>应用服务>服务总线>的通知中心通知中心>快速创建>给轮毂名>创建
后者,你可以在你的asp.net应用程序使用波纹管代码在启动应用程序调用此方法divice令牌/ API(不要紧,它是天蓝色或没有。)
//you can create class and get instance of the hub in constructor
private NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString("Your connectionstring", "your Notification hub name");
从您的Android应用程序。
public async string registerpushhandle(string handle = null)
{
try
{
string newRegistrationId = null;
if (handle != null)
{
var registrations = await hub.GetRegistrationsByChannelAsync(handle, 500);
foreach (RegistrationDescription registration in registrations)
{
if (newRegistrationId == null)
{
newRegistrationId = registration.RegistrationId;
}
else
{
await hub.DeleteRegistrationAsync(registration);
}
}
}
if (newRegistrationId == null) newRegistrationId = await hub.CreateRegistrationIdAsync();
}
catch (Exception ex)
{
}
return newRegistrationId
}
获得注册后id通过传递您的registrationid,plateform和device令牌调用此方法。
public async void registerpushid(string id, string platform, string handle)
{
try
{
RegistrationDescription registration = null;
switch (platform.ToLower())
{
case "mpns":
registration = new MpnsRegistrationDescription(handle);
break;
case "wns":
registration = new WindowsRegistrationDescription(handle);
break;
case "apns":
registration = new AppleRegistrationDescription(handle);
break;
case "gcm":
registration = new GcmRegistrationDescription(handle);
break;
}
registration.RegistrationId = id;
registration.Tags = new HashSet<string>();
registration.Tags.Add(handle);
registration.Tags.Add("yourcustometag");
try
{
await hub.CreateOrUpdateRegistrationAsync(registration);
}
catch (MessagingException e)
{
}
}
catch (Exception ex)
{
}
0
AMR,您可以使用pushsharp(https://github.com/Redth/PushSharp),它是一个完整的图书馆发送推送通知到Android,iOS设备等
这里的配置并让它运行指南: https://github.com/Redth/PushSharp/wiki/How-to-Configure-&-Send-GCM-Google-Cloud-Messaging-Push-Notifications-using-PushSharp
我已经在几个项目中使用过,效果很好。
希望它可以帮助
0
尝试以下链接为他们提供完全免费的无限推送通知于Android &是实现很简单:
希望t他的帮助。
相关问题
- 1. GCM推送通知与Asp.Net
- 2. 在Asp.net中推送通知
- 3. ASP.NET中的推送通知
- 4. 推送推送通知
- 5. 推送通知
- 6. 推送通知
- 7. 推送通知
- 8. 推送通知
- 9. 推送通知
- 10. 推送通知
- 11. 推送通知
- 12. ASP.NET推送通知使用响应
- 13. 从ASP.Net服务器推送通知
- 14. “暖”推出推送通知
- 15. Android - 推送通知
- 16. Linphone推送通知
- 17. OnsenUI:推送通知
- 18. 从推送通知
- 19. 推送通知 - Android
- 20. PubNub推送通知
- 21. 推送通知下
- 22. 推送通知Genexus
- 23. 推送通知android
- 24. woklight推送通知
- 25. FCM推送通知
- 26. didRegisterForRemoteNotificationsWithDeviceToken - 推送通知
- 27. 推送通知7.1
- 28. iPhone推送通知
- 29. Firebase推送通知
- 30. UWP推送通知