No visible @interface for 'MessagingService' declares the selector 'registerForRemoteNotifications'

Hello,

I’m trying to port my existing iOS implementation for push notifications from an old version to the latest Backendless version. I am using the latest backendless version using cocoapods. In the docs I found the following statement which I had not in my old code:

[backendless.messaging registerForRemoteNotifications];

This does not compile in Xcode. No visible @interface for ‘MessagingService’ declares the selector ‘registerForRemoteNotifications’. What could be causing this?

Thanks,
Maarten

Hi,I got in touch with our iOS developer, soon he will contact you to help solve this issue.

Thanks for patience.

Regards,
Stanislaw

Hi,

With Xcode8/iOS10 you need this code

if ([[NSProcessInfo processInfo] operatingSystemVersion].majorVersion >= 10) {
 
 UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
 [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound)
 completionHandler:^(BOOL granted, NSError * _Nullable error) {
 }];
 }
 else {
 UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
 UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
 [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
 }
 [[UIApplication sharedApplication] registerForRemoteNotifications];

instead
[backendless.messaging registerForRemoteNotifications];

We will fix the doc soon.

After including

#import <UserNotifications/UserNotifications.h>

that seems to do the trick. Does this code also work for iOS 8 & 9?

Yes, lines 8-12 for iOS 8 & 9