0
AndroidとWindowsのプッシュ通知を試しても問題ありません。しかし、iOS側では何か間違っています。Azure Notification Hub(Xamarin.iOS)からのプッシュ通知
私はAzureのテストから、これらのチュートリアル
- https://docs.microsoft.com/en-us/azure/notification-hubs/xamarin-notification-hubs-ios-push-notification-apns-get-started
- https://blog.xamarin.com/push-notifications-ios-azure-notification-hubs/
を使用して、私のXamarin.iOSアプリにプッシュ通知を追加しようとしています、私は、メッセージが正常に送信されました「だ送ったが一致するターゲットはありませんでした。
それがあるように私はすべての手順に従ってきたが、私はブレークポイントを置いたとき、私はいつも「IsRegistered = false」を取得:
AppDelegate.cs
私の質問がありprivate SBNotificationHub Hub { get; set; }
public const string ConnectionString = "Endpoint=sb://...";
public const string NotificationHubPath = "NotificationHubName...";
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
// Set our preferred notification settings for the app
var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
new NSSet());
// Register for notifications
UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
UIApplication.SharedApplication.RegisterForRemoteNotifications();
bool IsRegistered = UIApplication.SharedApplication.IsRegisteredForRemoteNotifications;
return true;
}
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
Hub = new SBNotificationHub(ConnectionString, NotificationHubPath);
Hub.UnregisterAllAsync(deviceToken, (error) =>
{
if (error != null)
{
// Error unregistering
return;
}
// Register this device with the notification hub
Hub.RegisterNativeAsync(deviceToken, null, (registerError) =>
{
if (registerError != null)
{
// Error registering
}
});
});
}
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
{
if (null != userInfo && userInfo.ContainsKey(new NSString("aps")))
{
// Get the aps dictionary from the alert payload
NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary;
}
}
。
- 登録していないのはなぜですか?
- なぜ私は登録していないのですか?
- XamarinはAzure Notification HubのiOS 11.0プッシュ通知をサポートしていますか?
注:私は
- のVisual Studio 2017を使用していますWindowsの10
- Mac OSのハイSieraバージョン10.13
- Xcodeのバージョン9.0.1
- VS上(バージョン15.4.0) Mac Community Version 7.2(ビルド636)
- iPhone 5S、iPhone 6、iPhone 6、iPhone 7、iPhone 8のテスト - iOS11.0
'RegisteredForRemoteNotifications'方法でコードを表示します。通知ハブに登録していますか? –
質問にRegisteredForRemoteNotificationsメソッドを追加しました。 – aliyasar
ブレークポイントを使用して結果を確認しましたか? Azureとの登録は決して行われない可能性があります。あなたが –