- Go to Android Studio “Tool > Firebase > cloud messaging >SetUp F.C.M > Connect to firebase (it will open ) Brauser)
- Create Firebase Account >Cuntineu > Connect
- open “https://console.firebase.google.com” open your account
- Click setting icon > project setting > Cloud messaging
- Enable Cloud Messaging API (Legacy)
- Go to service Account > Generet new private key > Generete (It will download the Service Account JSON)
One signal
- go to one signal Website “www.onesignal.com”
- Add new app/website > Name your project > Select google android > upload firebase Service Account JSON Continue
- Copy App Id
Setup app id on Android studio
- Add FCM To the app
- Setup accourding to this url ‘https://documentation.onesignal.com/docs/android-sdk-setup”
a. pase this code on “Build.gredil (app)” of dependencies
implementation 'com.onesignal:OneSignal:[5.0.0, 5.99.99]'
click Sync Now
b. Past this code on MainActivity.java “down to the private WebView mywebView;
private static final String ONESIGNAL_APP_ID = "7574f5d1-99fb-4912-bcde-2a85f3c93cc5";
c. Past this code on MainActivity.java “before the last colum of setContentView(R.layout.activity_main);
EXAMPLE
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Past code here
}
// Verbose Logging set to help debug issues, remove before releasing your app.
OneSignal.getDebug().setLogLevel(LogLevel.VERBOSE);
// OneSignal Initialization
OneSignal.initWithContext(this, ONESIGNAL_APP_ID);
// requestPermission will show the native Android notification permission prompt.
// NOTE: It's recommended to use a OneSignal In-App Message to prompt instead.
OneSignal.getNotifications().requestPermission(true, Continue.with(r -> {
if (r.isSuccess()) {
if (r.getData()) {
// `requestPermission` completed successfully and the user has accepted permission
}
else {
// `requestPermission` completed successfully but the user has rejected permission
}
}
else {
// `requestPermission` completed unsuccessfully, check `r.getThrowable()` for more info on the failure reason
}
}));






