admin管理员组文章数量:1025300
We have implemented the notifications and it works fine when we do the regular testing. However, when concurrent users uses the same API then we get below error.
The default firebaseapp already exists. However, by checking the solution on the internet, we have implemented the below solution in the class constructor
if (FirebaseApp.DefaultInstance == null)
{
FirebaseApp.Create(new AppOptions()
{
Credential = GoogleCredential.FromJson(JsonConvert.SerializeObject(<Passing Firebase Config here>))
});
}
Then sending the notification using this code:
string result = await FirebaseMessaging.DefaultInstance.SendAsync(message);
Still we are getting the error as default FirebaseApp already exists.
Any help on this is appreciated!
We have implemented the notifications and it works fine when we do the regular testing. However, when concurrent users uses the same API then we get below error.
The default firebaseapp already exists. However, by checking the solution on the internet, we have implemented the below solution in the class constructor
if (FirebaseApp.DefaultInstance == null)
{
FirebaseApp.Create(new AppOptions()
{
Credential = GoogleCredential.FromJson(JsonConvert.SerializeObject(<Passing Firebase Config here>))
});
}
Then sending the notification using this code:
string result = await FirebaseMessaging.DefaultInstance.SendAsync(message);
Still we are getting the error as default FirebaseApp already exists.
Any help on this is appreciated!
Share Improve this question edited Nov 18, 2024 at 14:11 marc_s 757k184 gold badges1.4k silver badges1.5k bronze badges asked Nov 18, 2024 at 14:03 XamDevXamDev 3,67713 gold badges63 silver badges104 bronze badges1 Answer
Reset to default 0import firebase_admin
from firebase_admin import credentials, firestore
class FirebaseManager:
def __init__(self):
if not firebase_admin._apps:
cred = credentials.Certificate('path/to/your/serviceAccountKey.json')
firebase_admin.initialize_app(cred, {
'databaseURL': 'https://your-database-url.firebaseio'
})
self.db = firestore.client()
# Usage
firebase_manager = FirebaseManager()
We have implemented the notifications and it works fine when we do the regular testing. However, when concurrent users uses the same API then we get below error.
The default firebaseapp already exists. However, by checking the solution on the internet, we have implemented the below solution in the class constructor
if (FirebaseApp.DefaultInstance == null)
{
FirebaseApp.Create(new AppOptions()
{
Credential = GoogleCredential.FromJson(JsonConvert.SerializeObject(<Passing Firebase Config here>))
});
}
Then sending the notification using this code:
string result = await FirebaseMessaging.DefaultInstance.SendAsync(message);
Still we are getting the error as default FirebaseApp already exists.
Any help on this is appreciated!
We have implemented the notifications and it works fine when we do the regular testing. However, when concurrent users uses the same API then we get below error.
The default firebaseapp already exists. However, by checking the solution on the internet, we have implemented the below solution in the class constructor
if (FirebaseApp.DefaultInstance == null)
{
FirebaseApp.Create(new AppOptions()
{
Credential = GoogleCredential.FromJson(JsonConvert.SerializeObject(<Passing Firebase Config here>))
});
}
Then sending the notification using this code:
string result = await FirebaseMessaging.DefaultInstance.SendAsync(message);
Still we are getting the error as default FirebaseApp already exists.
Any help on this is appreciated!
Share Improve this question edited Nov 18, 2024 at 14:11 marc_s 757k184 gold badges1.4k silver badges1.5k bronze badges asked Nov 18, 2024 at 14:03 XamDevXamDev 3,67713 gold badges63 silver badges104 bronze badges1 Answer
Reset to default 0import firebase_admin
from firebase_admin import credentials, firestore
class FirebaseManager:
def __init__(self):
if not firebase_admin._apps:
cred = credentials.Certificate('path/to/your/serviceAccountKey.json')
firebase_admin.initialize_app(cred, {
'databaseURL': 'https://your-database-url.firebaseio'
})
self.db = firestore.client()
# Usage
firebase_manager = FirebaseManager()
版权声明:本文标题:c# - Getting the default firebaseapp already exists in .NET Core while sending notifications - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745612164a2159067.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论