我有一個Xamarin Forms應用程序,我無法使推送通知在iOS中工作。他們在Android中工作正常。該設備正在使用SDK v4.1.0正式向Urban Airship註冊。我能夠獲得一個ChannelId和一個設備令牌。當我發送Dev信道時,Android設備會收到通知,但iOS設備不會。在Urban Airship中,Full Message Report顯示消息已發送到Android設備以及我已測試過的兩個iOS設備。我相信我錯過了一些小事,但我無法弄清楚它是什麼。以下是App Delegate的參考資料。從我見過的例子來看,這非常簡單。Xamarin Forms iOS設備不會收到來自Urban Airship的推送
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
using UrbanAirship;
namespace -----------.Mobile.iOS
{
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
UAConfig config = new UrbanAirship.UAConfig();
config.DevelopmentAppKey = "----------------------";
config.DevelopmentAppSecret = "----------------------";
config.ProductionAppKey = "----------------------";
config.ProductionAppSecret = "----------------------";
#if DEBUG
config.InProduction = false;
#else
config.InProduction = true
#endif
UAirship.TakeOff(config);
UAirship.Push.UserPushNotificationsEnabled = true;
UAirship.Push.ChannelTagRegistrationEnabled = true;
// Write the ChannelId for reference later.
Guid urbanAirshipChannelId;
UrbanAirshipData uaData = new UrbanAirshipData();
if (Guid.TryParse(UAirship.Push.ChannelID, out urbanAirshipChannelId))
{
uaData.UrbanAirshipChannelId = urbanAirshipChannelId;
uaData.UrbanAirshipDeviceType = Common.Utilities.Enumerations.eUrbanAirshipDeviceType.iOS;
}
UAirship.Push.PushNotificationDelegate = PushReceived();
LoadApplication(new App(uaData));
return base.FinishedLaunching(app, options);
}
private UAPushNotificationDelegate PushReceived()
{
UAPushNotificationDelegate result = new UAPushNotificationDelegate();
return result;
}
}
}
任何反饋或意見將不勝感激。
感謝您的回覆。我有個問題。 iOS中的預期行爲如下?當應用程序運行前臺並收到推送時,該設備將不會通知用戶,但通知將與其他通知一起列出?此外,您提到可以在UAPush實例中更改此設置。 我一直在看通知列表,當我試圖推動,沒有看到任何東西。我想我可能不得不發佈一個問題。我已聯繫過UA,但我們客戶的服務水平沒有支持。 – GX2TAP
蘋果公司認爲應用程序可以處理推送,並且不會向iOS 10發佈任何通知。現在,他們允許設置前臺演示文稿選項。你可以在這裏設置默認值 - http://docs.urbanairship.com/reference/libraries/ios/latest/Classes/UAPush.html#/c:objc(cs)UAPush(py)defaultPresentationOptions。他們可能會讓你在社區論壇發帖,但他們很快回復。 – ralepinski
謝謝。我會讓我的下一步。感謝您的反饋。 – GX2TAP