Push setup spans the delivery service, native application identity, permissions, and the Dart callbacks. This earlier example targeted onesignal_flutter ^2.3.4; its console and credential workflow is historical.
Native platform configuration
The source connected Firebase sender/server settings and an iOS certificate to OneSignal. It then registered the Android package and iOS bundle, placed platform configuration files in the host projects, and enabled iOS notification capabilities. Those files and credentials are not imported here.
The Android build changes were:
buildscript {
repositories {
// ...
maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
}
dependencies {
// ...
// OneSignal-Gradle-Plugin
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
<application
….
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_launcher_background" />
</application>
The final block is an excerpt, not a complete manifest. Plugin repositories and versions reflect the earlier build.
Dart initialization
onesignal_flutter: ^2.3.4
/// OneSignal Initialization
void initOneSignal(oneSignalAppId) {
var settings = {
OSiOSSettings.autoPrompt: true,
OSiOSSettings.inAppLaunchUrl: true
};
OneSignal.shared.init(oneSignalAppId, iOSSettings: settings);
OneSignal.shared
.setInFocusDisplayType(OSNotificationDisplayType.notification);
// will be called whenever a notification is received
OneSignal.shared
.setNotificationReceivedHandler((OSNotification notification) {
print('Received: ' + notification?.payload?.body ?? '');
});
// will be called whenever a notification is opened/button pressed.
OneSignal.shared
.setNotificationOpenedHandler((OSNotificationOpenedResult result) {
print('Opened: ' + result.notification?.payload?.body ?? '');
});
}
The setup distinguished received/opened notifications and configured prompting and foreground display. The old claim that no iOS simulator can receive notifications is not retained as a universal current rule.
Verify separate stages
A registered device, a subscription, an accepted send, delivery, and an opened notification are different observations. The source’s dashboard test instructions do not establish a new result. No notification, certificate, or service configuration was created for this revision.