How Can I program a notification push when my website public a new post?

Viewed 28

I am programming an Android app with Java with Android Studio. My app shows the website on screen and I would like to notificate the articles I will publish in the future. How can I do this? I have OneSignal Push in my webpage, if it is useful for the process

MainActivity

package secretosdemalaga.com;

import androidx.appcompat.app.AppCompatActivity;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.onesignal.OneSignal;



public class MainActivity extends AppCompatActivity {
    public WebView mywebView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    OneSignal.setLogLevel(OneSignal.LOG_LEVEL.VERBOSE, OneSignal.LOG_LEVEL.NONE);

    // OneSignal Inicializacion
    OneSignal.startInit(this)
            .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
            .unsubscribeWhenNotificationsAreDisabled(true)
            .init();
    // Ver Web en la app
    setContentView(R.layout.activity_main);
    mywebView = findViewById(R.id.am_webview);
    WebSettings ajustes = mywebView.getSettings();
    ajustes.setJavaScriptEnabled(true);
    mywebView.loadUrl("https://educacioninformatica.es");
    mywebView.setWebViewClient(new WebViewClient());


}


//Cerrar la app o volver atras
@Override
public void onBackPressed() {
    if (mywebView.canGoBack()) {
        mywebView.goBack();
    } else {
        super.onBackPressed();
    }
}

}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/caparefresco"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">


<WebView
    android:id="@+id/am_webview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

</RelativeLayout>
0 Answers
Related