Closed MrTarantula closed 4 years ago
I figured it out. It looks like the examples omit several needed imports, along with being outdated (no AndroidX). I use VS Code with no Java extensions installed so I wasn't getting the errors. I opened in Android Studio and immediately got reference errors. An update to step 3 of the instructions would look something like this:
package com.myorg.myapp;
import androidx.core.app.NotificationCompat;
import com.onesignal.OSNotificationDisplayedResult;
import com.onesignal.OSNotificationReceivedResult;
import com.onesignal.NotificationExtenderService;
import java.math.BigInteger;
public class NotificationExtenderExample extends NotificationExtenderService {
@Override
protected boolean onNotificationProcessing(OSNotificationReceivedResult receivedResult) {
OverrideSettings overrideSettings = new OverrideSettings();
overrideSettings.extender = new NotificationCompat.Extender() {
@Override
public NotificationCompat.Builder extend(NotificationCompat.Builder builder) {
// Sets the background notification color to Green on Android 5.0+ devices.
return builder.setColor(new BigInteger("FF00FF00", 16).intValue());
}
};
OSNotificationDisplayedResult displayedResult = displayNotification(overrideSettings);
//Log.d("OneSignalExample", "Notification displayed with id: " + displayedResult.androidNotificationId);
return true;
}
}
brilliant thank you
Closing as @MrTarantula figured out it
Same issue but my this import com.onesignal.NotificationExtenderService; Not not fixed, its showing error And all other onsignal. Objects I try latest dependency of Onsignal, old and from documentation but its still not fixed.
What I'll do please help to resolve this
Description:
I have installed the SDK and it works. I then followed the instructions to add the notification extender service in Android.
Environment
Steps to Reproduce Issue:
Anything else: