推送通知不會收到我的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推送通知