Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS10] UILocalNotification is deprecated from iOS10 and up #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions JSDecoupledAppDelegate/JSDecoupledAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define JSIOS8SDK (__IPHONE_OS_VERSION_MAX_ALLOWED >= 80000)
#define JSIOS8_2SDK (__IPHONE_OS_VERSION_MAX_ALLOWED >= 80200)
#define JSIOS9SDK (__IPHONE_OS_VERSION_MAX_ALLOWED >= 90000)
#define JSIOS10SDK (__IPHONE_OS_VERSION_MAX_ALLOWED >= 100000)

#if !__has_feature(nullability)
#define _Nonnull
Expand Down Expand Up @@ -107,7 +108,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler;
#endif

#if JSIOS8SDK
#if JSIOS10SDK
#elif JSIOS8SDK
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm why these 2?

Copy link

@ghost ghost Jan 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JaviSoto So didRegisterUserNotifications and handleActionWithIdentifier were both added in iOS8 but deprecated in iOS10.
and #if JSIOS8SDK condition is true for all iOS versions 8 and above. Hence I added an if for iOS10> where those methods are not registered

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, should this be #if JSIOS8SDK && ! JSIOS10SDK perhaps to make it more clear?

I think the JSIOXSDK macros should be renamed to like JSSDKAtLeastIOS9. That way this would be a bit clearer.

Alternatively, what I would like is to stop using those macros, and instead, add:

NS_DEPRECATED_IOS(8_0, 10_0)

What do you think?

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler NS_AVAILABLE_IOS(8_0);
#endif
Expand All @@ -120,13 +122,14 @@ NS_ASSUME_NONNULL_BEGIN

@protocol JSApplicationLocalNotificationsDelegate <NSObject>

#if JSIOS10SDK
#elif JSIOS8SDK
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification;

#if JSIOS8SDK
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler;
#endif

#if JSIOS9SDK
#if JSIOS10SDK
#elif JSIOS9SDK
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forLocalNotification:(UILocalNotification *)notification withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler NS_AVAILABLE_IOS(9_0);
#endif

Expand Down
16 changes: 11 additions & 5 deletions JSDecoupledAppDelegate/JSDecoupledAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N
}
#endif

#if JSIOS8SDK
#if JSIOS10SDK
#elif JSIOS8SDK
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
[self.remoteNotificationsDelegate application:application didRegisterUserNotificationSettings:notificationSettings];
Expand All @@ -265,26 +266,31 @@ - (void)application:(UIApplication *)application handleActionWithIdentifier:(nul

#pragma mark - JSApplicationLocalNotificationsDelegate

#if JSIOS10SDK
#elif JSIOS8SDK
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
[self.localNotificationsDelegate application:application didReceiveLocalNotification:notification];
}
#endif

#if JSIOS8SDK

#if JSIOS10SDK
#elif JSIOS8SDK
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler
{
[self.localNotificationsDelegate application:application handleActionWithIdentifier:identifier forLocalNotification:notification completionHandler:completionHandler];
}
#endif

#if JSIOS9SDK
#if JSIOS10SDK
#elif JSIOS9SDK
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forLocalNotification:(UILocalNotification *)notification withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler
{
[self.localNotificationsDelegate application:application handleActionWithIdentifier:identifier forLocalNotification:notification withResponseInfo:responseInfo completionHandler:completionHandler];
}
#endif

#endif


#pragma mark - JSApplicationStateRestorationDelegate

Expand Down