Reputation: 53
I have followed the tutorial provided by Microsoft found here
I have configured the Android version and it is working perfectly well.
My issue comes in that I can't receive push notifications. The one step states that I need to send a screen through to Azure to start sending and receiving data from Azure and to enable real time monitoring.
I am trying to send through the storyboard that is used as the landing page but because I don't have any other pages in my IOS project because the UI is in the PCL part of the project it doesn't seem to be working.
When the app starts up it requests the permissions for notifications, the certificates are correct as I have tested them with just a notification hub, the app even completes the registration process without issue but it still won't receive any notifications.
Below is the code for receiving, registering and failing to register:
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
{
EngagementAgent.ApplicationDidReceiveRemoteNotification(userInfo, completionHandler);
}
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
EngagementAgent.RegisterDeviceToken(deviceToken);
}
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
{
Console.WriteLine("Failed to register for remote notifications: Error '{0}'", error);
}
This is the setup code in AppDelegate:
EngagementConfiguration config = new EngagementConfiguration
{
ConnectionString = "",
NotificationIcon = UIImage.FromBundle("icon")
};
EngagementAgent.Init(config);
if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
{
var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
(UIUserNotificationType.Badge |
UIUserNotificationType.Sound |
UIUserNotificationType.Alert),
null);
UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
UIApplication.SharedApplication.RegisterForRemoteNotifications();
}
else
{
UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(
UIRemoteNotificationType.Badge |
UIRemoteNotificationType.Sound |
UIRemoteNotificationType.Alert);
}
I am not getting any exceptions or crashes. I am at a loss as to what the problem is.
Upvotes: 0
Views: 139
Reputation: 11
Have you enabled Silent Remote Notifications for your app?
To do that you need to add following lines to your plist.info
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
Upvotes: 1