我有一个JavaSpringBoot后端应用程序,我正试图连接到Firebase云消息。我有一个使用firebase的android应用程序,我正在尝试使用这个后端来推送通知。
我已经从Firebase控制台项目设置中生成了一个私钥,放置了json文件-下面的操作在本地非常完美:
try {
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(new ClassPathResource("PATH_TO_GENERATED_JSON").
getInputStream())).build();
if (FirebaseApp.getApps().isEmpty()) {
FirebaseApp.initializeApp(options);
logger.info("Firebase application has been initialized");
}
} catch (IOException e) {
logger.error(e.getMessage());
}
...
response = FirebaseMessaging.getInstance().send(message);
我已经设置了谷歌云构建来自动触发并从github构建。但是我不能提交json凭据文件(对吗?),所以对于云部署,我已经将初始化部分更改为:
if (FirebaseApp.getApps().isEmpty()) {
FirebaseApp.initializeApp();
logger.info("Firebase application has been initialized");
}
但我收到了有关未设置项目id的错误信息,因此我还使用以下命令编辑了cloud build触发器内联YAML:
--update-env-vars=GOOGLE_CLOUD_PROJECT=XXXXXXXXXXX
但现在我得到以下错误时,试图发送消息:
com.google.firebase.messagine.FirebaseMessagingException:权限'cloudmessaging.messages.create'denied on resource'//cloudresourcemanager.googleapis.com/projects/xxxxxxxxxxxxxx'(或者它可能不存在)。
(xxxxxxxxxx是我的项目id)
我已经开始给Firebase Cloud Messaging Admin(Firebase云消息管理员)的角色设置为左和右https://console.cloud.google.com/iam-admin/iam?project= 但这没有帮助:(
有人能帮忙吗?
添加堆栈跟踪:
com.google.firebase.messaging.FirebaseMessagingException: Permission 'cloudmessaging.messages.create' denied on resource '//cloudresourcemanager.googleapis.com/projects/our-shield-329019' (or it may not exist).
at com.google.firebase.messaging.FirebaseMessagingException.withMessagingErrorCode(FirebaseMessagingException.java:51)
at com.google.firebase.messaging.FirebaseMessagingClientImpl$MessagingErrorHandler.createException(FirebaseMessagingClientImpl.java:293)
at com.google.firebase.messaging.FirebaseMessagingClientImpl$MessagingErrorHandler.createException(FirebaseMessagingClientImpl.java:282)
at com.google.firebase.internal.AbstractHttpErrorHandler.handleHttpResponseException(AbstractHttpErrorHandler.java:57)
at com.google.firebase.internal.ErrorHandlingHttpClient.send(ErrorHandlingHttpClient.java:108)
at com.google.firebase.internal.ErrorHandlingHttpClient.sendAndParse(ErrorHandlingHttpClient.java:72)
at com.google.firebase.messaging.FirebaseMessagingClientImpl.sendSingleRequest(FirebaseMessagingClientImpl.java:127)
at com.google.firebase.messaging.FirebaseMessagingClientImpl.send(FirebaseMessagingClientImpl.java:113)
at com.google.firebase.messaging.FirebaseMessaging$1.execute(FirebaseMessaging.java:137)
at com.google.firebase.messaging.FirebaseMessaging$1.execute(FirebaseMessaging.java:134)
at com.google.firebase.internal.CallableOperation.call(CallableOperation.java:36)
at com.google.firebase.messaging.FirebaseMessaging.send(FirebaseMessaging.java:104)
at com.google.firebase.messaging.FirebaseMessaging.send(FirebaseMessaging.java:86)
at com.miloszdobrowolski.investobotbackend.InvestobotAPIs.testNotification(InvestobotAPIs.java:120)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1726)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: com.google.api.client.http.HttpResponseException: 403 Forbidden
如了解角色文档中所列,Firebase Cloud Messaging Admin没有cloudmessaging.messages.create
权限。要添加此权限,请使用以下角色之一:
我正在开发Android/iOS应用程序使用离子框架(网络技术),我想添加推通知与新的firebase功能FCM的帮助。 null 这是否意味着我可以在Android/iOS的ionic应用程序中使用它,因为应用程序是使用Cordova构建的?
我最近将我的iOS应用从一个开发人员帐户转移到另一个开发人员帐户,现在我无法从Firebase云消息发送推送通知到我的应用。我尝试了以下方法: null 很明显,FCM代币已经更新,问题在于我在苹果方面遗漏了/忘记了做什么,以允许FCM与APN对话,但我无法找出我做错了什么。有什么想法吗?
我也在尝试使用node。js和firebase管理员向iOS设备发送推送通知。然而,我遇到了这个错误: 错误发送消息:{错误:请求包含一个无效的参数。在Firebase MessagingError。错误(本机)在Firebase MessagingError。Firebase Error[作为构造函数](/user_code/node_modules/fire base-admin/lib/ut
我想使用谷歌的Firebase为网络构建一个消息应用程序。在这个应用程序中,用户应该向/从其他用户发送和接收消息。我检查了谷歌的Firebase网站,但我迷路了。你能告诉我从哪里开始吗?你能给我看任何与Firebase网络消息相关的教程或类似的东西吗?我欢迎任何建议。谢谢。
我必须在SpringJava中为多层架构制作一个RESTAPI,其中需要为Firebase云消息传递(FCM)构建DAO、控制器和服务管理器,以向android应用程序发送推送通知消息,但我无法在Java中配置服务器以向设备发送通知。我怎么能?
我试图从C#中的服务器发送推送通知,我使用了正确的注册令牌和API密钥,但仍然得到以下响应。 我按照这个网址来实现这个解决方案通过C#使用FCM(Firebase云消息传递)发送推送到Android 目前,我正在尝试向单个设备发送通知,但也希望同时向多个设备发送通知,我使用了url中给出的,但它不起作用。如果我必须同时向多个设备发送通知,我该怎么办? 这是我的密码