我正在尝试使用 Python Firebase Admin SDK 为我的移动应用程序发送推送通知。我已经使用 Firebase 控制台中的通知编辑器对其进行了测试,因此我知道我的设备可以接收推送通知,但当我尝试使用 SDK 时,我从未收到任何内容。我也没有看到 Firebase 控制台通知页面上列出的通知。
这是我用来发送通知的确切代码(减去我的个人信息):
import firebase_admin
from firebase_admin import credentials, messaging
token = "registration token"
creds = credentials.Certificate('path/to/cert.json')
app = firebase_admin.initialize_app(creds)
msg = messaging.Message(data={'title': 'Test'}, token=token)
print(messaging.send(msg, app=app))
Run Code Online (Sandbox Code Playgroud)
这会返回一个遵循格式的 URL /project/<project name>/messages/<message ID>,但该 URL 对我不起作用。它只会将我重定向到 Firebase 控制台基域和空白屏幕。另外,通知应该列在下面,/notifications不是吗?
所以我已经阅读了关于此的其他Stack帖子,他们都建议我使用find.我正在尝试这个,但它对我不起作用.
bool findInArray(int number, int array[]){
// Finds if the number is in the array
bool exists = find(begin(array), end(array), number) != end(array);
return exists;
Run Code Online (Sandbox Code Playgroud)
}
但我不断收到以下错误:
error: no matching function for call to ‘begin(int*&)’
Run Code Online (Sandbox Code Playgroud)
这里甚至是接受的答案:我如何检查数组中是否存在给定的int?