Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

I'm getting push notification errors 1012

Hello,

I hope someone can help me with this, I created a cross-platform app using Xamarin Forms and Visual Studiowever, some of my users are facing issues with push notifications that seem to be coming from the Apple side of things. It specifically seems to come from the moment the device tries to register itself for the notifications. The device gets an NSURLErrorDomain -1012.


We use Microsoft Azure notification hub to send out our notifications, recently some (not all) of my app users stopped receiving the notifications with the above error appearing in their logs. Trying the typical trouble shooting steps for not receiving notifications have not helped. iOS version seems to play no part in it and technical article TN2265 has not shed any light on it either.

Issue Definition

  • I've faced this issue for some months now.
  • Our app was developed using Xamarin Forms (iOS and Android) App a few months ago
  • Recently, some people have stopped receiving push notifications.
  • At first, it was just iOS but it has now progressed to Android too.
  • I have performed sopme investigations into what could be causing the problem, oddly it doesn't affect everyone.

Note
The app uses Mobile Services on Azure with a notification hub pointing to both APNS and Google Cloud Messaging

What I know so far

  • The OS you are running doesn't seem to make a difference.
  • It happens in both iOS and Android
  • Troubleshooting steps from the likes of Apple have not helped
  • Push notifications are turned on in all areas of the phone for the app
  • Deleting the app and reinstalling it makes no difference
  • When I connected one of the devices that had the issue to XCode to try and get some sense of what has gone wrong or is going wrong. I found in the error log was the following messages and they all seem related to Registration and Unregistering from the APNS.


Device Log

These are the only errors that I can find, it looks like the device is unauthorized but his not sure why or what he can do about it. Below is the code for registering and unregistering that is contained within AppDelegate in his iOS project of the Xamarin.Forms solution.

AppDelegate.cs


using System;
using Seabay;
using UIKit;
using Foundation;
using WindowsAzure.Messaging;
using Microsoft.WindowsAzure.MobileServices;
 
namespace Seabay.iOS
{ 
    [Register("AppDelegate")]
    public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
    {
        public SBNotificationHub hub { get; set; }
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
        //
        // #Types of Notications
    var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
 UIUserNotificationType.Alert |
 UIUserNotificationType.Badge |
 UIUserNotificationType.Sound,
 new NSSet());
 app.RegisterUserNotificationSettings(pushSettings);
 app.RegisterForRemoteNotifications();
 
 //
 //UI Tabbed Bar customisation
 UITabBar.Appearance.BackgroundColor = UIColor.FromRGBA(44, 62, 80, 1);
 UITabBar.Appearance.BarTintColor = UIColor.FromRGBA(44, 62, 80, 1);
 UITabBar.Appearance.SelectedImageTintColor = UIColor.White;
 
 // #Xamarin Forms init
 global::Xamarin.Forms.Forms.Init();
 
 // #Azure Mobile Services
 CurrentPlatform.Init(); 
 LoadApplication(new App());
 
 //
 //Just in case the notification is triggered here.
 ProcessNotification(options);
 
 return base.FinishedLaunching(app, options);
 }
 //
 //#RegisteredForRemoteNotifications
 public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
 {
 hub = new SBNotificationHub(Constants.ConnectionString, Constants.NotificationHubPath);
 
 hub.UnregisterAllAsync(deviceToken, (error) =>
 {
 if (error != null)
 {
 Console.WriteLine($"Error unregistering: {error}");
 }
 hub.RegisterNativeAsync(deviceToken, null, registerError =>
 {
 if (registerError != null)
 {
 Console.WriteLine($"Error registering: {registerError}");
 }
 });
 });
 }
 
 //
 //#Received Remote Notification
 public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
 {
 ProcessNotification(userInfo);
 }
 
 void ProcessNotification(NSDictionary options)
 {
 if (options == null)
 {
 return;
 }
 
 if (!options.ContainsKey(new NSString("aps")))
 {
 return;
 }
 var aps = options.ObjectForKey(new NSString("aps")) as NSDictionary;
 
 string alert = (aps[new NSString("alert")] as NSString).ToString();
 
 var alertCtr = UIAlertController.Create("Received Message!", alert, UIAlertControllerStyle.Alert);
 Window.RootViewController.ShowViewController(alertCtr, this);
 }
 }
 }




At this stage it's a case of trying to find out why the phones are failing to register. Any guidance on this issue would be greatly appreciated.

iPhone 7, iOS 11.2.6, All Apple and Andoird devices

Posted on Feb 27, 2018 5:40 AM

Reply

Similar questions

There are no replies.

I'm getting push notification errors 1012

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.