Permalink
Browse files

fix a bug with the foreground/isInline flag

previously the foreground/isInline flag was always set to NO.    Now it
will be set appropriately.
  • Loading branch information...
keithdmoore committed Apr 29, 2014
1 parent 857b438 commit 9f1766356d93e223f7678f9e53884e17d82a6467
Showing with 13 additions and 13 deletions.
  1. +10 −8 src/ios/AppDelegate+notification.m
  2. +3 −5 src/ios/PushPlugin.m
@@ -32,7 +32,7 @@ - (id) getCommandInstance:(NSString*)className
+ (void)load
{
Method original, swizzled;
-
+
original = class_getInstanceMethod(self, @selector(init));
swizzled = class_getInstanceMethod(self, @selector(swizzled_init));
method_exchangeImplementations(original, swizzled);
@@ -42,7 +42,7 @@ - (AppDelegate *)swizzled_init
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(createNotificationChecker:)
name:@"UIApplicationDidFinishLaunchingNotification" object:nil];
-
+
// This actually calls the original init method over in AppDelegate. Equivilent to calling super
// on an overrided method, this is not recursive, although it appears that way. neat huh?
return [self swizzled_init];
@@ -72,34 +72,36 @@ - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotif
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(@"didReceiveNotification");
-
+
// Get application state for iOS4.x+ devices, otherwise assume active
UIApplicationState appState = UIApplicationStateActive;
if ([application respondsToSelector:@selector(applicationState)]) {
appState = application.applicationState;
}
-
+
+ PushPlugin *pushHandler = [self getCommandInstance:@"PushPlugin"];
+
if (appState == UIApplicationStateActive) {
- PushPlugin *pushHandler = [self getCommandInstance:@"PushPlugin"];
pushHandler.notificationMessage = userInfo;
pushHandler.isInline = YES;
[pushHandler notificationReceived];
} else {
//save it for later
self.launchNotification = userInfo;
+ pushHandler.isInline = NO;
}
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
-
+
NSLog(@"active");
-
+
//zero badge
application.applicationIconBadgeNumber = 0;
if (![self.viewController.webView isLoading] && self.launchNotification) {
PushPlugin *pushHandler = [self getCommandInstance:@"PushPlugin"];
-
+
pushHandler.notificationMessage = self.launchNotification;
self.launchNotification = nil;
[pushHandler performSelectorOnMainThread:@selector(notificationReceived) withObject:pushHandler waitUntilDone:NO];
View
@@ -88,8 +88,6 @@ - (void)notificationReceived {
NSLog(@"Notification received");
if (notificationMessage && self.callbackId) {
- isInline = NO;
-
NSMutableDictionary *message = [[notificationMessage objectForKey:@"aps"] mutableCopy];
NSMutableDictionary *extraPayload = [notificationMessage mutableCopy];
[extraPayload removeObjectForKey:@"aps"];
@@ -139,9 +137,9 @@ - (void) saveConfig:(NSMutableDictionary *)dictionary {
[clientInfo setVariantSecret:[options objectForKey:@"variantSecret"]];
UIDevice *currentDevice = [UIDevice currentDevice];
- [clientInfo setOperatingSystem:[currentDevice systemName]];
- [clientInfo setOsVersion:[currentDevice systemVersion]];
- [clientInfo setDeviceType: [currentDevice model]];
+ [clientInfo setOperatingSystem:[currentDevice systemName]];
+ [clientInfo setOsVersion:[currentDevice systemVersion]];
+ [clientInfo setDeviceType: [currentDevice model]];
};
}

0 comments on commit 9f17663

Please sign in to comment.