繁体   English   中英

firebase 云消息不能从服务器工作

[英]firebase cloud messaging does not work from server

我正在尝试从我的服务器向我的 web 应用程序发送通知,它适用于我的本地项目,但是当我推送它时,firebase 不起作用

try {
     FirebaseOptions options = FirebaseOptions.builder()
          .setCredentials(GoogleCredentials.fromStream(
               new ClassPathResource("myapp-3c3c3-firebase-adminsdk-emn30-37a5092d63.json").getInputStream()))
           .setDatabaseUrl("https://myapp-3c3c3.firebaseio.com")
           .build();
            
     FirebaseApp.initializeApp(options);
      setInitialized();
} catch (IOException ignored) {
}

异常消息:

Unknown error while making a remote service call: Error getting access token for service account: 400 Bad Request
POST https://oauth2.googleapis.com/token
{"error":"invalid_grant","error_description":"Invalid JWT: Token must     be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim."}

json 配置文件位于 spring 项目的模块资源上

Message message = Message.builder()             
     .setNotification(Notification.builder().setTitle(title).setBody(contents).build())
      .setToken(token)
       .build();
return FirebaseMessaging.getInstance().send(message);

就我而言,问题在于服务器时间比实际时间晚了 10 分钟

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM