Skip to content

Commit

Permalink
Merge branch 'extended-support-lollipop' of https://github.com/rafael…
Browse files Browse the repository at this point in the history
…setragni/awesome_notifications into extended-support-lollipop
  • Loading branch information
rafaelsetragni committed Dec 8, 2021
2 parents 4d9ae7e + 5d30590 commit af21bab
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 66 deletions.
52 changes: 33 additions & 19 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,34 @@ public static Boolean removeChannel(Context context, String channelKey) {

public static NotificationChannelModel getChannelByKey(Context context, String channelKey){

if(StringUtils.isNullOrEmpty(channelKey))
if(StringUtils.isNullOrEmpty(channelKey)) {
if(AwesomeNotificationsPlugin.debug)
Log.e(TAG, "'"+channelKey+"' cannot be empty or null");
return null;
}

NotificationChannelModel channelModel = shared.get(context, Definitions.SHARED_CHANNELS, channelKey);
if(channelModel == null) return null;
if(channelModel == null) {
if(AwesomeNotificationsPlugin.debug)
Log.e(TAG, "Channel model '"+channelKey+"' was not found");
return null;
}

channelModel.refreshIconResource(context);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O /*Android 8*/){

NotificationChannel androidChannel = getAndroidChannel(context, channelKey);
if(androidChannel == null) return null;
if(androidChannel == null) {
if(AwesomeNotificationsPlugin.debug)
Log.e(TAG, "Android native channel '"+channelKey+"' was not found");
return null;
}

if(androidChannel.getImportance() == NotificationManager.IMPORTANCE_NONE){
if(AwesomeNotificationsPlugin.debug)
Log.e(TAG, "Android native channel '"+channelKey+"' is disabled");
}

updateChannelModelThroughAndroidChannel(channelModel, androidChannel);
}

Expand Down
7 changes: 0 additions & 7 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.1"
rxdart:
dependency: transitive
description:
name: rxdart
url: "https://pub.dartlang.org"
source: hosted
version: "0.27.2"
shared_preferences:
dependency: "direct main"
description:
Expand Down
14 changes: 6 additions & 8 deletions ios/Classes/lib/SwiftAwesomeNotificationsPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public class SwiftAwesomeNotificationsPlugin: NSObject, FlutterPlugin, UNUserNot
receiveAction(
jsonData: jsonData,
buttonKeyPressed: response.actionIdentifier,
userText: userText
userText: userText,
completionHandler: completionHandler
)
} else {
print("Received an invalid notification content")
Expand All @@ -60,9 +61,7 @@ public class SwiftAwesomeNotificationsPlugin: NSObject, FlutterPlugin, UNUserNot
// completionHandler was *not* called, so maybe this notification is for another plugin:

if _originalNotificationCenterDelegate?.userNotificationCenter?(center, willPresent: notification, withCompletionHandler: completionHandler) == nil {
// TODO(tek08): Absorb notifications like this? Or present them by default?
print("Was going to present a notification, but no plugin wanted to handle it.")
completionHandler([])
completionHandler([.alert, .badge, .sound])
}
}
}
Expand Down Expand Up @@ -320,7 +319,7 @@ public class SwiftAwesomeNotificationsPlugin: NSObject, FlutterPlugin, UNUserNot
}

#if !ACTION_EXTENSION
private func receiveAction(jsonData: String?, buttonKeyPressed:String?, userText:String?){
private func receiveAction(jsonData: String?, buttonKeyPressed:String?, userText:String?, withCompletionHandler: completionHandler){

if(SwiftAwesomeNotificationsPlugin.appLifeCycle == .AppKilled){
fireBackgroundLostEvents()
Expand All @@ -343,9 +342,8 @@ public class SwiftAwesomeNotificationsPlugin: NSObject, FlutterPlugin, UNUserNot
}
flutterChannel?.invokeMethod(Definitions.CHANNEL_METHOD_NOTIFICATION_DISMISSED, arguments: actionReceived?.toMap())
}
} else {
// Fallback on earlier versions
}
}
completionHandler()
}
#endif

Expand Down
25 changes: 12 additions & 13 deletions lib/src/awesome_notifications_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import 'package:awesome_notifications/src/models/received_models/received_notifi
import 'package:awesome_notifications/src/utils/assert_utils.dart';
import 'package:awesome_notifications/src/utils/bitmap_utils.dart';
import 'package:awesome_notifications/src/utils/date_utils.dart';
import 'package:rxdart/rxdart.dart' show BehaviorSubject;

import 'enumerators/notification_permission.dart';
import 'models/notification_channel_group.dart';
Expand Down Expand Up @@ -54,42 +53,42 @@ class AwesomeNotifications {
*/
/// STREAM CREATION METHODS *********************************************
final BehaviorSubject<ReceivedNotification>
final StreamController<ReceivedNotification>
// ignore: close_sinks
_createdSubject = BehaviorSubject<ReceivedNotification>();
_createdSubject = StreamController<ReceivedNotification>();

final BehaviorSubject<ReceivedNotification>
final StreamController<ReceivedNotification>
// ignore: close_sinks
_displayedSubject = BehaviorSubject<ReceivedNotification>();
_displayedSubject = StreamController<ReceivedNotification>();

final BehaviorSubject<ReceivedAction>
final StreamController<ReceivedAction>
// ignore: close_sinks
_actionSubject = BehaviorSubject<ReceivedAction>();
_actionSubject = StreamController<ReceivedAction>();

final BehaviorSubject<ReceivedAction>
final StreamController<ReceivedAction>
// ignore: close_sinks
_dismissedSubject = BehaviorSubject<ReceivedAction>();
_dismissedSubject = StreamController<ReceivedAction>();

/// STREAM METHODS *********************************************
/// Stream to capture all created notifications
Stream<ReceivedNotification> get createdStream {
return _createdSubject;
return _createdSubject.stream;
}

/// Stream to capture all notifications displayed on user's screen.
Stream<ReceivedNotification> get displayedStream {
return _displayedSubject;
return _displayedSubject.stream;
}

/// Stream to capture all notifications dismissed by the user.
Stream<ReceivedAction> get dismissedStream {
return _dismissedSubject;
return _dismissedSubject.stream;
}

/// Stream to capture all actions (tap) over notifications
Stream<ReceivedAction> get actionStream {
return _actionSubject;
return _actionSubject.stream;
}

/// SINK METHODS *********************************************
Expand Down
14 changes: 0 additions & 14 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
pedantic:
dependency: "direct dev"
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.0"
platform:
dependency: "direct main"
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
rxdart:
dependency: "direct main"
description:
name: rxdart
url: "https://pub.dartlang.org"
source: hosted
version: "0.27.2"
sky_engine:
dependency: transitive
description: flutter
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ dependencies:

#js: ^0.6.3
#meta: ^1.3.0
#rxdart: any

platform: any
intl: any
rxdart: any

dev_dependencies:
flutter_test:
sdk: flutter

pedantic: ^1.11.0
#pedantic: ^1.11.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down

0 comments on commit af21bab

Please sign in to comment.