Skip to content

Commit

Permalink
Brought back the iOS 7 methods now that I realized I was modifying th…
Browse files Browse the repository at this point in the history
…e wrong file all this time.
  • Loading branch information
JaviSoto committed Sep 16, 2013
1 parent ddb58e8 commit c51e845
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
16 changes: 16 additions & 0 deletions JSDecoupledAppDelegate/JSDecoupledAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@

#import <UIKit/UIKit.h>

#define JSIOS7SDK (__IPHONE_OS_VERSION_MAX_ALLOWED >= 70000)

@protocol JSApplicationStateDelegate;
@protocol JSApplicationDefaultOrientationDelegate;
@protocol JSApplicationBackgroundFetchDelegate;
@protocol JSApplicationRemoteNotificationsDelegate;
@protocol JSApplicationLocalNotificationsDelegate;
@protocol JSApplicationStateRestorationDelegate;
Expand All @@ -28,6 +31,7 @@

@property (strong, nonatomic) id<JSApplicationStateDelegate> appStateDelegate;
@property (strong, nonatomic) id<JSApplicationDefaultOrientationDelegate> appDefaultOrientationDelegate;
@property (strong, nonatomic) id<JSApplicationBackgroundFetchDelegate> backgroundFetchDelegate;
@property (strong, nonatomic) id<JSApplicationRemoteNotificationsDelegate> remoteNotificationsDelegate;
@property (strong, nonatomic) id<JSApplicationLocalNotificationsDelegate> localNotificationsDelegate;
@property (strong, nonatomic) id<JSApplicationStateRestorationDelegate> stateRestorationDelegate;
Expand Down Expand Up @@ -61,6 +65,14 @@

@end

@protocol JSApplicationBackgroundFetchDelegate <NSObject>

#if JSIOS7SDK
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler;
#endif

@end

@protocol JSApplicationRemoteNotificationsDelegate <NSObject>

@optional
Expand All @@ -69,6 +81,10 @@

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo;

#if JSIOS7SDK
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler;
#endif

@end

@protocol JSApplicationLocalNotificationsDelegate <NSObject>
Expand Down
18 changes: 18 additions & 0 deletions JSDecoupledAppDelegate/JSDecoupledAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
properties = @[
NSStringFromSelector(@selector(appStateDelegate)),
NSStringFromSelector(@selector(appDefaultOrientationDelegate)),
NSStringFromSelector(@selector(backgroundFetchDelegate)),
NSStringFromSelector(@selector(remoteNotificationsDelegate)),
NSStringFromSelector(@selector(localNotificationsDelegate)),
NSStringFromSelector(@selector(stateRestorationDelegate)),
Expand All @@ -64,6 +65,7 @@
protocols = @[
NSStringFromProtocol(@protocol(JSApplicationStateDelegate)),
NSStringFromProtocol(@protocol(JSApplicationDefaultOrientationDelegate)),
NSStringFromProtocol(@protocol(JSApplicationBackgroundFetchDelegate)),
NSStringFromProtocol(@protocol(JSApplicationRemoteNotificationsDelegate)),
NSStringFromProtocol(@protocol(JSApplicationLocalNotificationsDelegate)),
NSStringFromProtocol(@protocol(JSApplicationStateRestorationDelegate)),
Expand Down Expand Up @@ -197,6 +199,15 @@ - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrienta
return [self.appDefaultOrientationDelegate application:application supportedInterfaceOrientationsForWindow:window];
}

#pragma mark - JSApplicationBackgroundFetchDelegate

#if JSIOS7SDK
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler
{
[self.backgroundFetchDelegate application:application performFetchWithCompletionHandler:completionHandler];
}
#endif

#pragma mark - JSApplicationRemoteNotificationsDelegate

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
Expand All @@ -214,6 +225,13 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N
[self.remoteNotificationsDelegate application:application didReceiveRemoteNotification:userInfo];
}

#if JSIOS7SDK
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler
{
[self.remoteNotificationsDelegate application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
#endif

#pragma mark - JSApplicationLocalNotificationsDelegate

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
Expand Down
12 changes: 6 additions & 6 deletions JSDecoupledAppDelegate_SampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
D054E97617E7A356007D9673 /* JSDecoupledAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D054E97517E7A356007D9673 /* JSDecoupledAppDelegate.m */; };
D0C415E217DEDA75003F9C6E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C415E117DEDA75003F9C6E /* Foundation.framework */; };
D0C415E417DEDA75003F9C6E /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C415E317DEDA75003F9C6E /* CoreGraphics.framework */; };
D0C415E617DEDA75003F9C6E /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C415E517DEDA75003F9C6E /* UIKit.framework */; };
Expand All @@ -19,7 +20,6 @@
D0C4160517DEDA75003F9C6E /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = D0C4160317DEDA75003F9C6E /* InfoPlist.strings */; };
D0C4160717DEDA75003F9C6E /* JSDecoupledAppDelegate_SampleAppTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D0C4160617DEDA75003F9C6E /* JSDecoupledAppDelegate_SampleAppTests.m */; };
D0FE1E2517DEE6B70085A37B /* JSApplicationStateDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D0FE1E2417DEE6B70085A37B /* JSApplicationStateDelegate.m */; };
D0FE1E2B17DEF09C0085A37B /* JSDecoupledAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D0FE1E2A17DEF09C0085A37B /* JSDecoupledAppDelegate.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -33,6 +33,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
D054E97417E7A356007D9673 /* JSDecoupledAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSDecoupledAppDelegate.h; path = JSDecoupledAppDelegate/JSDecoupledAppDelegate.h; sourceTree = SOURCE_ROOT; };
D054E97517E7A356007D9673 /* JSDecoupledAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = JSDecoupledAppDelegate.m; path = JSDecoupledAppDelegate/JSDecoupledAppDelegate.m; sourceTree = SOURCE_ROOT; };
D0C415DE17DEDA75003F9C6E /* JSDecoupledAppDelegate_SampleApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JSDecoupledAppDelegate_SampleApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
D0C415E117DEDA75003F9C6E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
D0C415E317DEDA75003F9C6E /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
Expand All @@ -49,8 +51,6 @@
D0C4160617DEDA75003F9C6E /* JSDecoupledAppDelegate_SampleAppTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JSDecoupledAppDelegate_SampleAppTests.m; sourceTree = "<group>"; };
D0FE1E2317DEE6B70085A37B /* JSApplicationStateDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSApplicationStateDelegate.h; sourceTree = "<group>"; };
D0FE1E2417DEE6B70085A37B /* JSApplicationStateDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSApplicationStateDelegate.m; sourceTree = "<group>"; };
D0FE1E2917DEF09C0085A37B /* JSDecoupledAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDecoupledAppDelegate.h; sourceTree = "<group>"; };
D0FE1E2A17DEF09C0085A37B /* JSDecoupledAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSDecoupledAppDelegate.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -110,8 +110,8 @@
D0C415E717DEDA75003F9C6E /* JSDecoupledAppDelegate_SampleApp */ = {
isa = PBXGroup;
children = (
D0FE1E2917DEF09C0085A37B /* JSDecoupledAppDelegate.h */,
D0FE1E2A17DEF09C0085A37B /* JSDecoupledAppDelegate.m */,
D054E97417E7A356007D9673 /* JSDecoupledAppDelegate.h */,
D054E97517E7A356007D9673 /* JSDecoupledAppDelegate.m */,
D0C415F317DEDA75003F9C6E /* Images.xcassets */,
D0C415E817DEDA75003F9C6E /* Supporting Files */,
D0FE1E2317DEE6B70085A37B /* JSApplicationStateDelegate.h */,
Expand Down Expand Up @@ -245,7 +245,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D0FE1E2B17DEF09C0085A37B /* JSDecoupledAppDelegate.m in Sources */,
D054E97617E7A356007D9673 /* JSDecoupledAppDelegate.m in Sources */,
D0C415EE17DEDA75003F9C6E /* main.m in Sources */,
D0FE1E2517DEE6B70085A37B /* JSApplicationStateDelegate.m in Sources */,
);
Expand Down

0 comments on commit c51e845

Please sign in to comment.