Can't init OneSignal
OneSignal.shared.setLogLevel(OSLogLevel.verbose, OSLogLevel.verbose);
await OneSignal.shared.init(---myapid----);
in response have
V/OneSignal( 7769): Initializing the OneSignal Flutter SDK (0.1.0)
and that is ... next code after init line is not executed
dependancies:
onesignal: ^1.0.0
@yostrokon Can you try removing the await and tell me if push notifications work at all?
Also, does this occur in iOS or Android, or both?
Lastly, can you try explicitly using 1.0.1?
Sigh. This is also happening to me on iOS also, I'm using 1.0.1. I have removed the await also.
@Nightsd01
print('starting');
OneSignal.shared.setLogLevel(OSLogLevel.verbose, OSLogLevel.verbose);
OneSignal.shared.init(---------);
print('inited');
await OneSignal.shared.promptUserForPushNotificationPermission(fallbackToSettings: true);
print('asked');
response is
I/flutter ( 5132): starting
I/flutter ( 5132): inited
E/flutter ( 5132): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter ( 5132): NoSuchMethodError: The getter 'keys' was called on null.
E/flutter ( 5132): Receiver: null
E/flutter ( 5132): Tried calling: keys
E/flutter ( 5132): #0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:46:5)
E/flutter ( 5132): #1 OneSignal._processSettings (package:onesignal/onesignal.dart:302:40)
E/flutter ( 5132): #2 OneSignal.init (package:onesignal/onesignal.dart:54:25)
E/flutter ( 5132):
.
.
.
E/flutter ( 5132): #16 _drawFrame (dart:ui/hooks.dart:109:3)
E/onesignal( 5132): promptPermission() is not applicable in Android.
V/OneSignal( 5132): Initializing the OneSignal Flutter SDK (0.1.0)
Same with 1.0.1. No idea about iOS.
Something similar was happening to me, in my case I got it working once I supplied iOS settings as args to the init call.
I believe this line is the problem: https://github.com/OneSignal/OneSignal-Flutter-SDK/blob/d33b258f2e911286eb72c666343d3c4deadc7345/lib/onesignal.dart#L302
If a settings map is not supplied to init, it would be null here.
Very strange
onesignal init was as in the method called from the future builder in the application widget.
moved to the initState as shown in the example and seems something works.
Hey @yostrokon - can you clarify what you mean?
@FaisalAbid
I have complex authorization with the couple of the external services and all of them are collected in one method returning future that was called as future in the FutureBuilder. So was tried to do onesignal.init in the same method. But nothing happened as is this issue. Today installed example application from the onesignal package and it worked. Tried to move onesignal.init to the initState method as is implemented in the example and things are started.
I had to supply the iOSSettings. If you don't, an exception is thrown when the plugin tries to loop through its keys since it's null.
The docs and code is a bit misleading because it says you can you can pass null in Android and iOSSettings is a named argument that you can ignore.
Thanks, I'll check that
Still having the same issue.
E/onesignal(14453): promptPermission() is not applicable in Android.
Initialising like
dart
OneSignal.shared.init(oneSignalAppId, iOSSettings: {
OSiOSSettings.autoPrompt: false,
OSiOSSettings.inAppLaunchUrl: true
});
@lifenautjoe
did you solve this problem ?
use this instead
OneSignal.shared.setAppId("YOUR_ONESIGNAL_APP_ID");
Most helpful comment
I had to supply the iOSSettings. If you don't, an exception is thrown when the plugin tries to loop through its keys since it's null.
The docs and code is a bit misleading because it says you can you can pass null in Android and iOSSettings is a named argument that you can ignore.