I'm trying to receive FCM notification on android wear emulator running on Android Oreo API 26.
I have properly registered the app on firebase, the firebase token is being printed on the log and the notification channel is also being created.
I'm using the firebase console to send the message, but it is not receiving on the wear. The console says 0 messages sent, 0 received. I'm sending the notification from the console under the same name, via the notification channel testing_channel
.
Does it take time to receive on the wear?
Manifest declaration:
<service
android:name=".Services.NotificationInstanceService"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
Service Class:
public class NotificationInstanceService extends FirebaseInstanceIdService{
@Override
public void onTokenRefresh() {
String refreshedToken = FirebaseInstanceId.getInstance().getToken() ;
Log.i("TAG", "onTokenRefresh: " + refreshedToken);
}
}
AppController:
public class AppController extends Application{
@Override
public void onCreate() {
super.onCreate();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
String id = "testing_channel";
CharSequence name = "Testing";
String description = "This channel is primarily for testing";
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel mChannel = null;
mChannel = new NotificationChannel(id, name, importance);
mChannel.setDescription(description);
mChannel.enableLights(true);
mChannel.setLightColor(Color.RED);
mChannel.enableVibration(true);
mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
mNotificationManager.createNotificationChannel(mChannel);
Log.i("TAG", "onCreate: NOTIFICATION CHANNEL CREATED" );
}
}
}