2

I've been looking into testing remote notifications using the simulator and know that starting with Xcode 11.4 beta, we should be able to do that.

The way I'm trying to test this is:

  1. On the app launching inside didFinishLaunchingWithOptions, I'm doing:

[[UIApplication sharedApplication] registerForRemoteNotifications];

  1. I've added the callbacks as follows:
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    NSLog( @"Succeeded at registering for remote notifications" );
    return;
 }

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
    NSLog( @"Failed to register for remote notifications" );
    return;

}

I'm hitting the breakpoint in didFailToRegisterForRemoteNotificationsWithError and the error is: remote notifications are not supported in the simulator

Is there a way around it? Am I misunderstanding the feature being supported in XCode 11.4?

user81
  • 21
  • 1
  • 2
  • 1
    You have misunderstood a little. The simulator can't register for remote notifications. You can drop a JSON file with the notification payload on the simulator to "deliver" that notification to your app – Paulw11 Apr 04 '20 at 01:37
  • So is my understanding right that in this case I would be testing the notification flow (receiving the notification, etc) but without the registering part? As in even if the registering is failing, I would still be able to continue testing notifications using this new feature? – user81 Apr 04 '20 at 20:38
  • That's correct. To test registration you still need to ru on an actual device. – Paulw11 Apr 04 '20 at 20:39
  • Thank you so much @Paulw11! – user81 Apr 05 '20 at 21:02

0 Answers0