Skip to content

Commit

Permalink
Merge pull request #773 from OneSignal/fix/ci
Browse files Browse the repository at this point in the history
Fix CI errors
  • Loading branch information
shepherd-l authored Dec 14, 2023
2 parents 0996e59 + fa95dff commit 6bfc79a
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '2.10.4'
flutter-version: '3.3.2'
channel: 'stable'

- name: Checkout OneSignal-Flutter-SDK
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class _MyAppState extends State<MyApp> {
// Toggle pausing (displaying or not) of IAMs
OneSignal.InAppMessages.paused(true);
var arePaused = await OneSignal.InAppMessages.arePaused();
print('Notifications paused ${arePaused}');
print('Notifications paused $arePaused');
}

oneSignalOutcomeExamples() async {
Expand Down
7 changes: 7 additions & 0 deletions lib/onesignal_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,19 @@ class OneSignal {
/// Note that the iOS and Android native libraries are static,
/// so if you create multiple instances of OneSignal, they will
/// mostly share the same state.
// ignore: non_constant_identifier_names
static OneSignalDebug Debug = new OneSignalDebug();
// ignore: non_constant_identifier_names
static OneSignalUser User = new OneSignalUser();
// ignore: non_constant_identifier_names
static OneSignalNotifications Notifications = new OneSignalNotifications();
// ignore: non_constant_identifier_names
static OneSignalSession Session = new OneSignalSession();
// ignore: non_constant_identifier_names
static OneSignalLocation Location = new OneSignalLocation();
// ignore: non_constant_identifier_names
static OneSignalInAppMessages InAppMessages = new OneSignalInAppMessages();
// ignore: non_constant_identifier_names
static OneSignalLiveActivities LiveActivities = new OneSignalLiveActivities();

// private channels used to bridge to ObjC/Java
Expand Down
1 change: 0 additions & 1 deletion lib/src/inappmessage.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:onesignal_flutter/onesignal_flutter.dart';
import 'package:onesignal_flutter/src/utils.dart';

/// When a click action is defined on an In App Message form the dashboard,
Expand Down
8 changes: 2 additions & 6 deletions lib/src/notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,7 @@ class OSNotificationWillDisplayEvent extends JSONStringRepresentable {
}

void preventDefault() {
if (notification != null) {
OneSignal.Notifications.preventDefault(notification.notificationId);
}
OneSignal.Notifications.preventDefault(notification.notificationId);
}

String jsonRepresentation() {
Expand All @@ -383,9 +381,7 @@ class OSNotificationClickEvent extends JSONStringRepresentable {
}

void preventDefault() {
if (notification != null) {
OneSignal.Notifications.preventDefault(notification.notificationId);
}
OneSignal.Notifications.preventDefault(notification.notificationId);
}

String jsonRepresentation() {
Expand Down
1 change: 0 additions & 1 deletion lib/src/notifications.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:io';
import 'package:flutter/services.dart';
import 'package:onesignal_flutter/src/defines.dart';
import 'package:onesignal_flutter/src/notification.dart';
import 'package:onesignal_flutter/src/permission.dart';

typedef void OnNotificationPermissionChangeObserver(bool permission);

Expand Down
26 changes: 13 additions & 13 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ dynamic convertEnumCaseToValue(dynamic key) {
}

switch (key) {
case OSSession.DIRECT:
return "DIRECT";
case OSSession.INDIRECT:
return "INDIRECT";
case OSSession.UNATTRIBUTED:
return "UNATTRIBUTED";
case OSSession.DISABLED:
return "DISABLED";
case OSSession.DIRECT:
return "DIRECT";
case OSSession.INDIRECT:
return "INDIRECT";
case OSSession.UNATTRIBUTED:
return "UNATTRIBUTED";
case OSSession.DISABLED:
return "DISABLED";
}

return key;
Expand All @@ -78,9 +78,9 @@ dynamic convertEnumCaseToValue(dynamic key) {
abstract class JSONStringRepresentable {
String jsonRepresentation();

String convertToJsonString(Map<String, dynamic>? object) => JsonEncoder
.withIndent(' ')
.convert(object)
.replaceAll("\\n", "\n")
.replaceAll("\\", "");
String convertToJsonString(Map<String, dynamic>? object) =>
JsonEncoder.withIndent(' ')
.convert(object)
.replaceAll("\\n", "\n")
.replaceAll("\\", "");
}
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: onesignal_flutter
description: OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
version: 5.0.4
author: Brad Hesse <brad@onesignal.com>, Josh Kasten <josh@onesignal.com>, Henry Boswell <henryboswell@onesignal.com>
homepage: https://github.com/OneSignal/OneSignal-Flutter-SDK

flutter:
Expand Down
4 changes: 3 additions & 1 deletion test/mock_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import 'package:flutter_test/flutter_test.dart';

class OneSignalMockChannelController {
MethodChannel _channel = const MethodChannel('OneSignal');
MethodChannel _debugChannel = const MethodChannel('OneSignal#debug');
MethodChannel _tagsChannel = const MethodChannel('OneSignal#tags');

late OneSignalState state;

OneSignalMockChannelController() {
this._channel.setMockMethodCallHandler(_handleMethod);
this._tagsChannel.setMockMethodCallHandler(_handleMethod);
this._debugChannel.setMockMethodCallHandler(_handleMethod);
}

void resetState() {
Expand Down Expand Up @@ -117,7 +119,7 @@ class OneSignalState {
}

void setLogLevel(Map<dynamic, dynamic> params) {
int? level = params['console'] as int?;
int? level = params['logLevel'] as int?;
int? visual = params['visual'] as int?;

if (level != null) this.logLevel = OSLogLevel.values[level];
Expand Down
3 changes: 1 addition & 2 deletions test/onesignalflutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ void main() {

OneSignalMockChannelController channelController =
OneSignalMockChannelController();
OneSignal onesignal = OneSignal();

setUp(() {
channelController.resetState();
});

test('set set log level', () {
test('set log level', () {
OneSignal.Debug.setLogLevel(
OSLogLevel.info,
).then(expectAsync1((v) {
Expand Down

0 comments on commit 6bfc79a

Please sign in to comment.