通过代码强制更改/更新Firebase通知令牌或实例ID? [英] Change/update Firebase notification token or instance id forcefully via code?
问题描述
我应该怎么做才能更改或请求Firebase中的令牌?
由firebase根据设备信息生成的唯一标记。
现在我面对很多人
1)删除旧的Firebase令牌
<$ p $ $ b $ FIRInstanceID.instanceID()。delete {(err:Error?)in $ b $)$ {code> let instance = FIRInstanceID.instanceID()
_ = FIRInstanceID.delete(instance)
b if err!= nil {
print(err.debugDescription);
} else {
print(Token Deleted);
$ b
2)申请新的Firebase标记
$如果令牌= FIRInstanceID.instanceID()。token(){print(Token \(token)fetched); b
$ b
} else {
print(Unable to fetch token);
$ b FIRMessaging.messaging()。connect {(error)in
if(error!= nil){
print(连接到FCM的错误。 \\(error.debugDescription))
} else {
print(Connected to FCM。)
}
}
What should I do that for changing or requesting the token in firebase? the unique token generated by firebase on the basis of device information.
Now i got my answer after facing many troubles for generating new or change token of firebase for push notification.
1) Delete old Firebase token
let instance = FIRInstanceID.instanceID()
_ = FIRInstanceID.delete(instance)
FIRInstanceID.instanceID().delete { (err:Error?) in
if err != nil{
print(err.debugDescription);
} else {
print("Token Deleted");
}
}
2) Request new Firebase token
if let token = FIRInstanceID.instanceID().token() {
print("Token \(token) fetched");
} else {
print("Unable to fetch token");
}
FIRMessaging.messaging().connect { (error) in
if (error != nil) {
print("Error connecting to FCM. \(error.debugDescription)")
} else {
print("Connected to FCM.")
}
}
这篇关于通过代码强制更改/更新Firebase通知令牌或实例ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!