将Wordpress通知与Android应用程序集成

时间:2019-07-28 17:24:31

标签: android wordpress android-studio webview notifications

我已经为我的Wordpress网站创建了一个Webview应用程序,还向Wordpress添加了一个插件以将通知与我的应用程序集成在一起,但是我似乎无法正确编写代码。该应用程序是接收通知,但是当我单击它们时,它会打开主页而不是帖子,我也应该能够选择要通知的类别。

我已经正确集成了Firebase消息传递,并按照说明添加了库。网站端没有问题,唯一剩下的就是与应用程序集成...

这是插件的网站,他们在其中提供代码: https://products.delitestudio.com/wordpress/push-notifications-for-wordpress/push-notifications-library-for-android/

如果可以帮助,请这样做。几天来一直让我发疯,没有结果

这是我MainActivity的一部分:

String myCurrentUrl;
    private SwipeRefreshLayout swipe;
    private ValueCallback<Uri> mUploadMessage;
    public ValueCallback<Uri[]> uploadMessage;
    public static final int REQUEST_SELECT_FILE = 100;
    private final static int FILECHOOSER_RESULTCODE = 1;



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    swipe = findViewById(R.id.swipe);
    swipe.setOnRefreshListener(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mywebView = (WebView) findViewById(R.id.webView);
    WebSettings webSettings = mywebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    mywebView.loadUrl("https://www.qalamgroup.com/");
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setAllowContentAccess(true);
    mywebView.getSettings().setDomStorageEnabled(true);
    webSettings.getJavaScriptCanOpenWindowsAutomatically();
    webSettings.setAppCacheEnabled(true);
    webSettings.supportMultipleWindows();

    new PushNotifications.Builder(this, "https://qalamgroup.com/pnfw/register/")
            .build();



@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    Bundle extras = intent.getExtras();
    int id = Integer.parseInt(extras.getString(PushNotifications.ID));
    String title = extras.getString(PushNotifications.TITLE);
}

private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        mIntentReceiver.abortBroadcast();

        Bundle extras = intent.getExtras();
        int id = Integer.parseInt(extras.getString(PushNotifications.ID));
        String title = extras.getString(PushNotifications.TITLE);

    }
};

}

0 个答案:

没有答案