Problems with Push Notifications using Wordpress+OneSignal+Android

Hi there,

How do I open Push Notificstions sent from my Wordpress Blog via OneSignal in the Android App and not in the browser?
This topic keeps me busy but I cannot seem to find the correct solution.

I came across this code here but its not working either

import android.app.Application;
import android.content.Intent;
import android.util.Log;
import com.onesignal.OSNotificationAction;
import com.onesignal.OSNotificationOpenResult;
import com.onesignal.OSNotification;
import com.onesignal.OSNotificationPayload;
import com.onesignal.OneSignal;
import org.json.JSONObject;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;


public class Activity1 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        WebView webview = (WebView) findViewById(R.id.webView);

        OneSignal.startInit(this)
                .setNotificationOpenedHandler(new ExampleNotificationOpenedHandler())
                .init();
    }
    private class ExampleNotificationOpenedHandler implements OneSignal.NotificationOpenedHandler {
        public void notificationOpened(String message, JSONObject additionalData, boolean isActive) {
            if (additionalData != null && additionalData.has("https://www.example.com"))
                webView.loadUrl(additionalData.optString("https://www.example.com"));
        }
    }
}

Open in new window


The error message is
Error:(31, 13) error: Activity1.ExampleNotificationOpenedHandler is not abstract and does not override abstract method notificationOpened(OSNotificationOpenResult) in NotificationOpenedHandler
Error:(34, 17) error: cannot find symbol variable webView
MartinAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WordPress

From novice to tech pro — start learning today.