使用curl命令发送推式通知时注册错误无效 [英] Invalid registration error on sending push notification using curl command

查看:501
本文介绍了使用curl命令发送推式通知时注册错误无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了客户端代码接收推送通知使用服务工作者在我的网络应用程序,我运行在本地主机上的应用程序。如何调用通知。我已经包含了一个包含sender_id的manifest.json。



从FCM的命令行发送请求以推送消息,引用 https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications /
在终端执行curl命令时,得到无效的注册错误。

  {multicast_id :xxxxxxxxx,success:0,failure:1,canonical_ids:0,results:[{error:InvalidRegistration}]} 
/ pre>

我已经验证了服务器密钥和端点订阅ID,他们是正确的。但是问题是什么?



我使用chrome web服务器托管了我的应用程序,但是如何sendpush通知呢?



我已经创建了一个示例项目Sample-App,我已将其托管在Chrome网络服务器上 http://127.0.0.1: 8888 ,并且在firebase中我创建了带有示例应用程序名称的项目,将生成API服务器密钥和gcm_sender_id。



我也通过托管我的代码github上有https url,仍然是同一个问题

解决方案

过去两周我一直在努力解决这个问题。
最后它现在工作。
问题是,在regId我得到...在之间。这是抛出无效的注册错误。
regid在控制台正在修剪的内容到中...。
所以就在console.log之前,你可以检查reg id,它显示可以从curl命令使用的完整的id。
它按预期工作。推送通知弹出。


I have written the client side code to receive the push notifications using service workers in my web app, Im running the app on localhost. How to invoke the notifications. I have included a manifest.json with sender_id.

Send a request from the command line for FCM to push a message, referred https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/ While executing curl command in terminal, I get the invalid registration error.

{"multicast_id":xxxxxxxxx,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}

I have verified server key and endpoint subscription ID, they are correct. But what is the issue ?

I have hosted my app using chrome web server, but how can I sendpush notification?

I have created a sample project Sample-App, I have hosted it on chrome webserver http://127.0.0.1:8888, and in firebase I have created project with Sample-App name which will generate API server key and gcm_sender_id.

I have also checked by hosting my code on github with https url, still the same issue

解决方案

I have been struggling with this issue past two weeks. Finally it works now. Issue is that, in regId I'm getting ... in between. That was throwing the invalid registration error. regid in console is trimming the content to ... in middle. So just before console.log you can check for reg id, it shows the complete id that you can use from curl command. It works as expected. Push notification pops up.

这篇关于使用curl命令发送推式通知时注册错误无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆