Wordpress 推送通知 Android 应用

Wordpress Push Notifications Android App

我真的很难打开 Wordpress 发送到我的 Android 项目的推送通知。 OneSignal 发送的测试通知会触发应用程序打开,但当我在 Wordpress 上发布文章时,通知会通过,但单击后正常浏览器会打开。

我已经一遍又一遍地阅读 OneSignal AndroidSDK,但我似乎无法理解和实施它。当我使用下面的代码时,来自 OneSignal Messaging System 的通知会触发应用程序打开。

    public class MyApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        OneSignal.startInit(this)
                .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
                .unsubscribeWhenNotificationsAreDisabled(true)
                .setNotificationReceivedHandler(new ExampleNotificationReceivedHandler())
                .init();

        // Call syncHashedEmail anywhere in your app if you have the user's email.
        // This improves the effectiveness of OneSignal's "best-time" notification scheduling feature.
        // OneSignal.syncHashedEmail(userEmail);
    }
}

我也在看 OneSignal 的 ExampleNotificationReceivedHandler教程,但是一旦文章发布,它只会打开普通浏览器,而不是应用程序。

我忽略了什么?

您可以在应用程序的网络视图中显示您的网站,但这需要进行一些自定义。

在您的 wordpress 插件中关闭此开关:https://imgur.com/a/yb8Ob

您将需要向您的 wordpress 站点添加额外的代码,请先阅读这篇关于如何向您的 wordpress 站点添加自定义代码的文章:https://documentation.onesignal.com/docs/web-push-wordpress-faq#section-where-should-the-code-be-placed-

然后按照此处有关如何设置自定义代码的说明进行操作,以便在您添加到应用的网络视图中显示通知: https://documentation.onesignal.com/docs/web-push-wordpress-faq#section-opening-web-and-mobile-notifications-in-the-browser-and-app