Merge branch 'charlesmchen/debugNotifications'

pull/1/head
Matthew Chen 7 years ago
commit f55012e671

@ -529,6 +529,12 @@ static NSTimeInterval launchStartedAt;
// We want to process up to one local notification per activation, so clear the flag.
self.hasReceivedLocalNotification = NO;
// Clear all notifications whenever we become active.
// When opening the app from a notification,
// AppDelegate.didReceiveLocalNotification will always
// be called _before_ we become active.
[application cancelAllLocalNotifications];
DDLogInfo(@"%@ applicationDidBecomeActive completed.", self.logTag);
}
@ -646,6 +652,9 @@ static NSTimeInterval launchStartedAt;
DDLogWarn(@"%@ applicationWillResignActive.", self.logTag);
// Clear all notifications whenever we become inactive.
[application cancelAllLocalNotifications];
[DDLog flushLog];
}

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSCallNotificationsAdaptee.h"
@ -17,6 +17,12 @@ NS_ASSUME_NONNULL_BEGIN
- (void)clearAllNotifications;
#ifdef DEBUG
+ (void)presentDebugNotification;
#endif
@end
NS_ASSUME_NONNULL_END

@ -449,6 +449,11 @@
notification.alertBody = notification.alertBody.filterStringForDisplay;
DispatchMainThreadSafe(^{
if (UIApplication.sharedApplication.applicationState == UIApplicationStateActive) {
DDLogWarn(@"%@ skipping notification; app is in foreground and active.", self.logTag);
return;
}
// Replace any existing notification
// e.g. when an "Incoming Call" notification gets replaced with a "Missed Call" notification.
if (self.currentNotifications[identifier]) {
@ -477,6 +482,22 @@
});
}
#ifdef DEBUG
+ (void)presentDebugNotification
{
OWSAssertIsOnMainThread();
UILocalNotification *notification = [UILocalNotification new];
notification.category = Signal_Full_New_Message_Category;
notification.soundName = [OWSSounds filenameForSound:OWSSound_DefaultiOSIncomingRingtone];
notification.alertBody = @"test";
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
#endif
- (void)clearAllNotifications
{
OWSAssertIsOnMainThread();

Loading…
Cancel
Save