如發現以下錯誤就是p8的憑證忘記再上傳新開的app裡,
誤以為先前測試APP上傳一次就可以一直通用XD
"error": {
"code": "messaging/invalid-apns-credentials",
"message": "A message targeted to an iOS device could not be sent because the required APNs SSL certificate was not uploaded or has expired. Check the validity of your development and production certificates."
}
星期一, 3月 25, 2019
星期二, 3月 19, 2019
[Nodejs] Use emitter.setMaxListeners() to increase limit 事件監聽超過最大限制
發現nodejs噴出了Use emitter.setMaxListeners() to increase limit 的警告,
找到stackoverflow的討論,但也有人說明是不是要把on 用once取代掉或有on被寫在for回圈裡面。
By default, a maximum of 10 listeners can be registered for any single event.
If it's your code, you can specify maxListeners via:
const emitter = new EventEmitter()
emitter.setMaxListeners(100)
// or 0 to turn off the limit
emitter.setMaxListeners(0)
But if it's not your code you can use the trick to increase the default limit globally:
require('events').EventEmitter.prototype._maxListeners = 100;
Of course you can turn off the limits but be careful:
// turn off limits by default (BE CAREFUL)
require('events').EventEmitter.prototype._maxListeners = 0;
BTW. The code should be at the very beginning of the app.
ADD: Since node 0.11 this code also works to change the default limit:
require('events').EventEmitter.defaultMaxListeners = 0
星期三, 3月 06, 2019
[FCM] 如何在web端取得registration token
如何在用戶的 web client端產生網頁的registration token
https://firebase.google.com/docs/cloud-messaging/js/client#access_the_registration_token
https://firebase.google.com/docs/cloud-messaging/js/client#access_the_registration_token
[FCM] firebase常見q&a
- Do I have to unsubscribe the old token and subscribe the new token to topics?
AFAIK, you don't have to unsubscribe the old token, since it will be discarded by FCM itself. For the new token, yes, you'll have to subscribe it to the topic you need. The usual thing is done (in Android) by having
subscribeToTopic()
in onTokenRefreshed()
.
- Do I have to remove the old token and add the new token to device groups?
Yes. You have to handle the mapping/relationships for Device Group Messaging. See my answer here. This is different from topics. The token will be invalidated, but will be kept as part of the list of registration tokens for the corresponding registration key.
It's why there's a possibility to receive a
NotRegistred
error on one of the tokens if you send to Device Group. :)
- Is it possible to get information about device groups/topics for a token?
For Device Group Messaging (same with #2), the developer (you) have to manage these details yourself. For topics, you can use the InstanceID API. Specifically, set
details
parameter to true
:[optional] booleandetails
: set this query parameter totrue
to get available IID token details, including connection information and FCM or GCM topic subscription information (if any) for the device associated with this token. When not specified, defaults tofalse
.
- Can I add a token to a device group more than once?
Ahmm. Yes. Do you mean the same token? If so, I haven't tried it yet. Might as well do some checking on the client side before adding.
- Can I subscribe a token to a topic more than once?
If you mean re-subscribing, then yes. If you mean duplicate request to subscribe, I think the result would still be a success. No changes in behavior though.
- Will multiple subscriptions/additions of the same token result in receiving duplicate messages?
Tested it out. You won't receive duplicate messages for both duplicate topic subscriptions and adding the same token to a device group. It seems that FCM ignores the request to subscribe/add a Registration token if it's already subscribed/added to a device group.
訂閱:
文章 (Atom)