簡體   English   中英

如何在應用前台制作信號推送通知警報

[英]How to make onesignal push-notification alert in app foreground

我希望我的OneSignal推送通知在前台發出警報。 當應用未在手機背景中運行時,我希望通知提醒。 我的背景警報已經完成了。

OneSignal.startInit(this)
                .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
                .unsubscribeWhenNotificationsAreDisabled(true)
                .init();

我希望即使應用程序沒有在后台運行,該應用程序也會通知手機。 (那是前景通知)

創建一個名為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);
    }

並將此類添加到如下所示的清單中

<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">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM