| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -55,20 +55,20 @@ class PushUtils { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    for (final message in Uri(query: utf8.decode(messages)).queryParameters.values) { | 
					 | 
					 | 
					 | 
					    for (final message in Uri(query: utf8.decode(messages)).queryParameters.values) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      final data = json.decode(message) as Map<String, dynamic>; | 
					 | 
					 | 
					 | 
					      final data = json.decode(message) as Map<String, dynamic>; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      final notification = PushNotification( | 
					 | 
					 | 
					 | 
					      final pushNotification = PushNotification( | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        accountID: instance, | 
					 | 
					 | 
					 | 
					        accountID: instance, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        priority: data['priority']! as String, | 
					 | 
					 | 
					 | 
					        priority: data['priority']! as String, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        type: data['type']! as String, | 
					 | 
					 | 
					 | 
					        type: data['type']! as String, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        subject: decryptPushNotificationSubject(keypair.privateKey, data['subject']! as String), | 
					 | 
					 | 
					 | 
					        subject: decryptPushNotificationSubject(keypair.privateKey, data['subject']! as String), | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      ); | 
					 | 
					 | 
					 | 
					      ); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      if (notification.subject.delete ?? false) { | 
					 | 
					 | 
					 | 
					      if (pushNotification.subject.delete ?? false) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        await localNotificationsPlugin.cancel(_getNotificationID(instance, notification)); | 
					 | 
					 | 
					 | 
					        await localNotificationsPlugin.cancel(_getNotificationID(instance, pushNotification)); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      } else if (notification.subject.deleteAll ?? false) { | 
					 | 
					 | 
					 | 
					      } else if (pushNotification.subject.deleteAll ?? false) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        await localNotificationsPlugin.cancelAll(); | 
					 | 
					 | 
					 | 
					        await localNotificationsPlugin.cancelAll(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Global.onPushNotificationReceived?.call(instance); | 
					 | 
					 | 
					 | 
					        Global.onPushNotificationReceived?.call(instance); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      } else if (notification.type == 'background') { | 
					 | 
					 | 
					 | 
					      } else if (pushNotification.type == 'background') { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        debugPrint('Got unknown background notification ${json.encode(notification.toJson())}'); | 
					 | 
					 | 
					 | 
					        debugPrint('Got unknown background notification ${json.encode(pushNotification.toJson())}'); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      } else { | 
					 | 
					 | 
					 | 
					      } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        final localizations = await appLocalizationsFromSystem(); | 
					 | 
					 | 
					 | 
					        final localizations = await appLocalizationsFromSystem(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -76,38 +76,46 @@ class PushUtils { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        final cache = Cache(platform); | 
					 | 
					 | 
					 | 
					        final cache = Cache(platform); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        await cache.init(); | 
					 | 
					 | 
					 | 
					        await cache.init(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        var appName = localizations.appImplementationName(notification.subject.app ?? ''); | 
					 | 
					 | 
					 | 
					        NextcloudNotificationsNotification? notification; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        try { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          final account = loadAccounts(AppStorage('accounts', sharedPreferences)).find(instance); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          if (account != null) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            notification = | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                (await account.client.notifications.getNotification(id: pushNotification.subject.nid!)).ocs.data; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } catch (e, s) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          debugPrint(e.toString()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          debugPrint(s.toString()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        final appID = notification?.app ?? pushNotification.subject.app ?? 'nextcloud'; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        var appName = localizations.appImplementationName(appID); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (appName == '') { | 
					 | 
					 | 
					 | 
					        if (appName == '') { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          debugPrint('Missing app name for ${notification.subject.app}'); | 
					 | 
					 | 
					 | 
					          debugPrint('Missing app name for $appID'); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          appName = notification.subject.app ?? 'Nextcloud'; | 
					 | 
					 | 
					 | 
					          appName = appID; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        final title = notification?.subject ?? pushNotification.subject.subject; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        final message = notification != null && notification.message != '' ? notification.message : null; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        await localNotificationsPlugin.show( | 
					 | 
					 | 
					 | 
					        await localNotificationsPlugin.show( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          _getNotificationID(instance, notification), | 
					 | 
					 | 
					 | 
					          _getNotificationID(instance, pushNotification), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          appName, | 
					 | 
					 | 
					 | 
					          message != null ? '$appName: $title' : appName, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          notification.subject.subject, | 
					 | 
					 | 
					 | 
					          message ?? title, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          NotificationDetails( | 
					 | 
					 | 
					 | 
					          NotificationDetails( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            android: AndroidNotificationDetails( | 
					 | 
					 | 
					 | 
					            android: AndroidNotificationDetails( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              notification.subject.app ?? 'nextcloud', | 
					 | 
					 | 
					 | 
					              appID, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              appName, | 
					 | 
					 | 
					 | 
					              appName, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              groupKey: notification.subject.app != null ? 'app_${notification.subject.app}' : 'nextcloud', | 
					 | 
					 | 
					 | 
					              groupKey: 'app_$appID', | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              icon: '@mipmap/ic_launcher', | 
					 | 
					 | 
					 | 
					              icon: '@mipmap/ic_launcher', | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              color: themePrimaryColor, | 
					 | 
					 | 
					 | 
					              color: themePrimaryColor, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              category: notification.type == 'voip' ? AndroidNotificationCategory.call : null, | 
					 | 
					 | 
					 | 
					              category: pushNotification.type == 'voip' ? AndroidNotificationCategory.call : null, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              importance: Importance.max, | 
					 | 
					 | 
					 | 
					              importance: Importance.max, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              priority: notification.priority == 'high' | 
					 | 
					 | 
					 | 
					              priority: pushNotification.priority == 'high' | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                  ? (notification.type == 'voip' ? Priority.max : Priority.high) | 
					 | 
					 | 
					 | 
					                  ? (pushNotification.type == 'voip' ? Priority.max : Priority.high) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                  : Priority.defaultPriority, | 
					 | 
					 | 
					 | 
					                  : Priority.defaultPriority, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            ), | 
					 | 
					 | 
					 | 
					            ), | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          ), | 
					 | 
					 | 
					 | 
					          ), | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          payload: json.encode( | 
					 | 
					 | 
					 | 
					          payload: json.encode(pushNotification.toJson()), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            PushNotification( | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              accountID: instance, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              priority: notification.priority, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              type: notification.type, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              subject: notification.subject, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            ).toJson(), | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          ), | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        ); | 
					 | 
					 | 
					 | 
					        ); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      } | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |