Android 树莓派上的东西 - 从 firebase 发送推送通知

Android things on raspberry - Send push notification from firebase

我正在制作一个 POC,其中我从 firebase 控制台向树莓派 运行 android 东西发送通知。

当代码在智能手机上时,这很好用,当我把它移到树莓派上时,就再也没有用了。我可以在 raspberry 控制台(在 Android Studio 中)看到通知在某种程度上被 rpi3 看到了,但是没有触发 onMessageReceived...

这是一些代码:

我的清单:

<service
    android:enabled="true"
    android:exported="true"
    android:name=".MyFirebaseMessagingService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>

订阅者:

private void subscribeToPushService() {
    FirebaseMessaging.getInstance().subscribeToTopic("news");

    Log.d("AndroidBash", "Subscribed");
    Toast.makeText(MainActivity.this, "Subscribed", Toast.LENGTH_SHORT).show();

    String token = FirebaseInstanceId.getInstance().getToken();
}

服务:

public class MyFirebaseMessagingService extends FirebaseMessagingService {

    private static final String TAG = "FirebaseMessageService";

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Log.d(TAG, "NOTIF");
    }
}

最后是我用 firebase 控制台发送的通知,我真的不明白我哪里搞砸了,包名似乎没问题...

感谢阅读!

似乎 DP5 of Android Things still didn't support Firebase Notifications (from Official Overview):

Android Things supports a subset of the Google APIs for Android. The following table breaks down API support in Android Things:

Unavailable APIs:

AdMob

Android Pay

Drive

Firebase App Indexing

Firebase Authentication

Firebase Dynamic Links

Firebase Invites

Firebase Notifications

Play Games

Sign-In