forked from mirrors/linphone-iphone
Fixes notification actions not showing
Checks notifiction allowed at every app becom active Added error message if notifications are not allowed
This commit is contained in:
parent
5374471827
commit
8a3030d4fb
3 changed files with 39 additions and 11 deletions
|
|
@ -159,6 +159,33 @@
|
||||||
[self handleShortcut:_shortcutItem];
|
[self handleShortcut:_shortcutItem];
|
||||||
_shortcutItem = nil;
|
_shortcutItem = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge)
|
||||||
|
completionHandler:^(BOOL granted, NSError *_Nullable error) {
|
||||||
|
if (error)
|
||||||
|
LOGD(error.description);
|
||||||
|
if (!granted) {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
UIAlertController *errView =
|
||||||
|
[UIAlertController alertControllerWithTitle:NSLocalizedString(@"Push notification not allowed", nil)
|
||||||
|
message:NSLocalizedString(@"Push notifications are required to receive calls and messages.", nil)
|
||||||
|
preferredStyle:UIAlertControllerStyleAlert];
|
||||||
|
|
||||||
|
UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"OK"
|
||||||
|
style:UIAlertActionStyleDefault
|
||||||
|
handler:^(UIAlertAction *action){
|
||||||
|
}];
|
||||||
|
[errView addAction:defaultAction];
|
||||||
|
[PhoneMainView.instance.mainViewController presentViewController:errView animated:YES completion:nil];
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[self configureUINotification];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma deploymate push "ignored-api-availability"
|
#pragma deploymate push "ignored-api-availability"
|
||||||
|
|
@ -227,15 +254,9 @@
|
||||||
options:UNNotificationCategoryOptionCustomDismissAction];
|
options:UNNotificationCategoryOptionCustomDismissAction];
|
||||||
|
|
||||||
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
|
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
|
||||||
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge)
|
|
||||||
completionHandler:^(BOOL granted, NSError *_Nullable error) {
|
|
||||||
// Enable or disable features based on authorization.
|
|
||||||
if (error)
|
|
||||||
LOGD(error.description);
|
|
||||||
}];
|
|
||||||
|
|
||||||
NSSet *categories = [NSSet setWithObjects:cat_call, cat_msg, video_call, cat_zrtp, nil];
|
NSSet *categories = [NSSet setWithObjects:cat_call, cat_msg, video_call, cat_zrtp, nil];
|
||||||
[[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:categories];
|
[[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:categories];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma deploymate pop
|
#pragma deploymate pop
|
||||||
|
|
@ -278,9 +299,7 @@
|
||||||
|
|
||||||
BOOL background_mode = [instance lpConfigBoolForKey:@"backgroundmode_preference"];
|
BOOL background_mode = [instance lpConfigBoolForKey:@"backgroundmode_preference"];
|
||||||
BOOL start_at_boot = [instance lpConfigBoolForKey:@"start_at_boot_preference"];
|
BOOL start_at_boot = [instance lpConfigBoolForKey:@"start_at_boot_preference"];
|
||||||
|
|
||||||
[self configureUINotification];
|
|
||||||
|
|
||||||
if (state == UIApplicationStateBackground) {
|
if (state == UIApplicationStateBackground) {
|
||||||
// we've been woken up directly to background;
|
// we've been woken up directly to background;
|
||||||
if (!start_at_boot || !background_mode) {
|
if (!start_at_boot || !background_mode) {
|
||||||
|
|
@ -523,6 +542,10 @@
|
||||||
completionHandler(UNNotificationPresentationOptionAlert);
|
completionHandler(UNNotificationPresentationOptionAlert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
||||||
didReceiveNotificationResponse:(UNNotificationResponse *)response
|
didReceiveNotificationResponse:(UNNotificationResponse *)response
|
||||||
withCompletionHandler:(void (^)(void))completionHandler {
|
withCompletionHandler:(void (^)(void))completionHandler {
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@
|
||||||
<dict>
|
<dict>
|
||||||
<key>UNNotificationExtensionCategory</key>
|
<key>UNNotificationExtensionCategory</key>
|
||||||
<string>msg_cat</string>
|
<string>msg_cat</string>
|
||||||
|
<key>UNNotificationExtensionDefaultContentHidden</key>
|
||||||
|
<false/>
|
||||||
<key>UNNotificationExtensionInitialContentSizeRatio</key>
|
<key>UNNotificationExtensionInitialContentSizeRatio</key>
|
||||||
<real>0.01</real>
|
<real>0.01</real>
|
||||||
<key>UNNotificationExtensionOverridesDefaultTitle</key>
|
<key>UNNotificationExtensionOverridesDefaultTitle</key>
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi
|
||||||
#endif
|
#endif
|
||||||
NSLog("[msgNotificationContent] start msgNotificationContent extension")
|
NSLog("[msgNotificationContent] start msgNotificationContent extension")
|
||||||
|
|
||||||
|
|
||||||
let replyAction = UNTextInputNotificationAction(identifier: "Reply",
|
let replyAction = UNTextInputNotificationAction(identifier: "Reply",
|
||||||
title: NSLocalizedString("Reply", comment: ""),
|
title: NSLocalizedString("Reply", comment: ""),
|
||||||
options: [],
|
options: [],
|
||||||
|
|
@ -61,7 +62,9 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi
|
||||||
coreStopped = false
|
coreStopped = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func didReceive(_ notification: UNNotification) {}
|
func didReceive(_ notification: UNNotification) {
|
||||||
|
VFSUtil.log("Notification received \(notification.request.content.userInfo) category \(notification.request.content.categoryIdentifier)",.info)
|
||||||
|
}
|
||||||
|
|
||||||
func didReceive(_ response: UNNotificationResponse,
|
func didReceive(_ response: UNNotificationResponse,
|
||||||
completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) {
|
completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue