【问题标题】:Firebase push notification `deprecatedEndPoint` errorFirebase 推送通知`deprecatedEndPoint` 错误
【发布时间】:2023-03-22 03:50:01
【问题描述】:

我在尝试从 PHP 服务器发送通知时收到 DeprecatedEndPoint 错误。

我正在为 FCM 使用“com.google.firebase:firebase-messaging:11.8.0”。

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    //noinspection GradleCompatible
//    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    //noinspection GradleCompatible
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation 'com.google.firebase:firebase-core:11.8.0'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'

    implementation 'com.google.android.gms:play-services-auth:8.3.0'
    //noinspection GradleCompatible
    implementation "com.google.android.gms:play-services-gcm:9.2.1"
}

以下是我在清单文件中声明的 firebase java 类:

public class MyFirebaseMessagingService extends FirebaseMessagingService {
    private static final String TAG = MyFirebaseMessagingService.class.getSimpleName();
    private String CHANNEL_ID = "1234";
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {

        final Uri alarmSound = Uri.parse("android.resource://com.clickaway.notificationdemo.pushnotificationdemo/raw/customsound");

        NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this, CHANNEL_ID)
                .setContentTitle(remoteMessage.getNotification().getTitle())
                .setContentText(remoteMessage.getNotification().getBody())
                .setPriority(NotificationCompat.PRIORITY_DEFAULT)
                .setStyle(new NotificationCompat.BigTextStyle())
                .setDefaults(DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setAutoCancel(true);
        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(0, notificationBuilder.build());      
    }
}

【问题讨论】:

  • 请添加一些代码让我们告诉您任何事情。
  • 如果您从 PHP 服务器获得该调用,则可能与您使用的客户端库无关。您更有可能调用的是旧端点。最新的 API 位于 https://fcm.googleapis.com/fcm/send 下。有关这方面的更多信息,请参阅firebase.google.com/docs/cloud-messaging/migrate-v1
  • 添加 fcm.googleapis.com/fcm/send 对我有用,谢谢

标签: java android firebase firebase-cloud-messaging


【解决方案1】:

将您的端点 URL 更改为此 - https://fcm.googleapis.com/fcm/send

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-05
    • 2018-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-18
    • 1970-01-01
    相关资源
    最近更新 更多