Reputation: 113
I want my OneSignal push-notification to alert in foreground. I want notification to alert when the app is not running in phone's background. I already have my background alert working.
OneSignal.startInit(this)
.inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
.unsubscribeWhenNotificationsAreDisabled(true)
.init();
I expect the app to notify phones even when the app is not running in background. (That s foreground notification )
Upvotes: 1
Views: 1185
Reputation: 980
Create a class named application class
public class ApplicationClass extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
OneSignal.startInit(this)
.inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
.unsubscribeWhenNotificationsAreDisabled(true).setNotificationOpenedHandler(new NotificationOpenHandler(this))
.init();
}
@Override
protected void attachBaseContext(Context context) {
super.attachBaseContext(context);
MultiDex.install(this);
}
and add this class to manifest like below
<application
android:name=".ApplicationClass"
android:allowBackup="true"
android:fullBackupContent="false"
android:icon="@mipmap/ic_icon_updated"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
Upvotes: 1