ios icon indicating copy to clipboard operation
ios copied to clipboard

Assigning to 'id<UNUserNotificationCenterDelegate> _Nullable' from incompatible type 'AppDelegate *const __strong'

Open mydesweb opened this issue 5 years ago • 10 comments

I have configured this library as described in documentation and I see this Warning Assigning to 'id<UNUserNotificationCenterDelegate> _Nullable' from incompatible type 'AppDelegate *const __strong'

after adding Inside didFinishLaunchingWithOptions // Define UNUserNotificationCenter UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; center.delegate = self;

on iOS Deployment Target 10.0+ I have even more Warnings:

'UIUserNotificationSettings' is deprecated: first deprecated in iOS 10.0 - Use UserNotifications Framework's UNNotificationSettings 'UILocalNotification' is deprecated: first deprecated in iOS 10.0 - Use UserNotifications Framework's UNNotificationRequest

mydesweb avatar Feb 29 '20 12:02 mydesweb

As per Apples's documentation UNUserNotificationCenter is only available from iOS 10+. You'll need to check iOS version in conditional. Additionally this block is only needed if you want to handle notifications when app is in the foreground.

dominiczaq avatar Feb 29 '20 14:02 dominiczaq

@dominiczaq actually you will see this warning no matter the target is. I think that the documentation and also the library itself need some updates because some statements are either not supported or deprecated..

mydesweb avatar Feb 29 '20 16:02 mydesweb

I believe there is no warning when I've changed the target to iOS 10+.

Documentation should probably mention that this part is only needed for foreground notification handling and it only supports iOS 10+ (the rest of lib works fine in iOS 9)

dominiczaq avatar Feb 29 '20 16:02 dominiczaq

@dominiczaq the warning is still there

mydesweb avatar Feb 29 '20 16:02 mydesweb

Any updates regarding this warning?

mstaicu avatar Mar 23 '20 12:03 mstaicu

Added this to my AppDelegate.h and the warning went away:

#import <UserNotifications/UNUserNotificationCenter.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>

dmoss18 avatar Jul 08 '20 18:07 dmoss18

Added this to my AppDelegate.h and the warning went away:

#import <UserNotifications/UNUserNotificationCenter.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>

This one is works for me Thank you

snehadange avatar May 31 '21 09:05 snehadange

i am getting this error with react native version 0.71.13 and my AppDelegate.h file is using RCTAppDelegate. I am trying to upgrade from 0.70.5 so can't use

// @interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate> in my AppDelegate.h file

Abfareye avatar Sep 17 '23 12:09 Abfareye

@Abfareye See this instructions: https://github.com/react-native-push-notification/ios/pull/392/files

katerynakostikova avatar Oct 06 '23 10:10 katerynakostikova

Added this to my AppDelegate.h and the warning went away:

#import <UserNotifications/UNUserNotificationCenter.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>

this worked thanks : #import <UserNotifications/UNUserNotificationCenter.h> @interface AppDelegate : RCTAppDelegate <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>

Blackbird312 avatar Dec 26 '23 11:12 Blackbird312