如何通过移动设备在 WearOs 上设置 firebase 通知

问题描述 投票:0回答:0

我有一个适用于 Android 移动和 wear-os 的应用程序,其包名与配套应用程序相同。当他们的通知出现在我的应用程序的移动设备上并且移动设备未被使用时,手表会收到通知,我想从此通知打开手表应用程序,但手表上有一个选项,如在手机中显示,但他们没有打开伴侣的选项应用程序。他们是否可以选择从手机收到的默认通知中打开手表应用程序以进行观看?谢谢

我正在使用这个代码

 /*******************************************
     * Wear Notification Block Started
     *********************************************/

    Intent wearAppIntent = new Intent(this, WearMainActivity.class);

    PendingIntent wearAppPendingIntent = PendingIntent.getActivity(this, 108, wearAppIntent, PendingIntent.FLAG_IMMUTABLE);

    NotificationCompat.Action wearAppAction = new NotificationCompat.Action.Builder(R.drawable.ic_stat_ic_notification, "Open Wear App", wearAppPendingIntent).build();


    /*******************************************
     * Wear Notification Block Ended
     *********************************************/

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
    notificationBuilder
            .setSmallIcon(R.drawable.ic_stat_ic_notification)
            .setContentTitle(title)
            .setContentText(body)
            .setTicker(body)
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent)
            //.setOngoing(true)
            .addAction(wearAppAction);
            //.extend(new NotificationCompat.WearableExtender().setContentAction(0)).addAction(wearAppAction);

任何帮助将不胜感激。

谢谢!

firebase android-push-notification android-wear-notification
© www.soinside.com 2019 - 2024. All rights reserved.