Skip to content

Commit 230e3dd

Browse files
committed
Fix Initialization Exception
• The init() method is intended to accept iOS Settings as an optional parameter • However it appears that it would cause an exception if settings were not provided. • Added regression test case to ensure init() works without iOS Settings
1 parent 2c6fcd2 commit 230e3dd

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/onesignal.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ class OneSignal {
299299
Map<String, dynamic> _processSettings(Map<OSiOSSettings, dynamic> settings) {
300300
var finalSettings = Map<String, dynamic>();
301301

302+
if (settings == null) return finalSettings;
303+
302304
for (OSiOSSettings key in settings.keys) {
303305
var settingsKey = convertEnumCaseToValue(key);
304306
var settingsValue = convertEnumCaseToValue(settings[key]);

test/onesignal_test.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ void main() {
2121
}));
2222
});
2323

24+
test('verify initialization without iOS Settings', () {
25+
onesignal.init(testAppId);
26+
expect(channelController.state.appId, testAppId);
27+
});
28+
2429
test('set set log level', () {
2530
onesignal
2631
.setLogLevel(OSLogLevel.info, OSLogLevel.warn)

0 commit comments

Comments
 (0)