我真的很想打开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
教程,但是一旦文章发布,它就会打开普通浏览器,而不是应用程序。
我在俯瞰什么?
答案 0 :(得分:0)
您可以在应用的网页浏览中显示您的网站,但这需要进行一些自定义。
在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