Skip to content

Commit

Permalink
Add support for displaying notifications
Browse files Browse the repository at this point in the history
Since we repurposed notification display for logging, and then turned it off
because it was too distracting, we didn't have a way to just display
notifications. This change adds a new method to display notifications, and
refactors existing code to invoke it when necessary. This seems to be a fix for
e-mission/e-mission-data-collection#113
  • Loading branch information
shankari committed Jul 26, 2016
1 parent 59b690d commit a0ba403
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/ios/LocalNotificationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
+(void)clearNotifications;
+(void)addNotification:(NSString*) notificationMessage;
+(void)addNotification:(NSString*) notificationMessage showUI:(BOOL)showUI;
+(void)showNotification:(NSString*) notificationMessage;

@end
10 changes: 6 additions & 4 deletions src/ios/LocalNotificationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ +(void)addNotification:(NSString *)notificationMessage {

+(void)addNotification:(NSString *)notificationMessage showUI:(BOOL)showUI {
NSLog(@"%@", notificationMessage);
if (showUI) {
notificationCount++;
}
NSString* level = @"DEBUG";
if (showUI) {
level = @"INFO";
Expand All @@ -39,13 +36,18 @@ +(void)addNotification:(NSString *)notificationMessage showUI:(BOOL)showUI {
// This is not a good thing, but it works for now
// Filed https://github.com/e-mission/e-mission-data-collection/issues/113 to track longer term issue
if (showUI && [ConfigManager instance].simulate_user_interaction) {
[LocalNotificationManager showNotification:notificationMessage];
}
}

+(void)showNotification:(NSString *)notificationMessage {
notificationCount++;
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif) {
localNotif.alertBody = notificationMessage;
localNotif.applicationIconBadgeNumber = notificationCount;
[[UIApplication sharedApplication] presentLocalNotificationNow:localNotif];
}
}
}

@end

0 comments on commit a0ba403

Please sign in to comment.