【发布时间】:2017-03-02 15:25:32
【问题描述】:
我有一个 Xamarin Forms 应用程序,我无法在 iOS 中获得推送通知。他们在 Android 中运行良好。该设备正在使用其 SDK v4.1.0 正确注册到 Urban Airship。我能够获得 ChannelId 和设备令牌。当我在 Dev 通道上发送推送时,Android 设备会收到通知,但 iOS 设备不会。在 Urban Airship 中,完整消息报告显示消息已发送到 Android 设备以及我测试过的两台 iOS 设备。我确定我错过了一些小东西,但我无法弄清楚它是什么。以下是来自 App Delegate 的源代码作为参考。从我看到的例子来看,这很简单。
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 xamarin xamarin.forms urbanairship.com