如何将 FirebaseAuth 用户传递给 Riverpod 中的 StreamProvider?
使用旧的提供程序包时,我曾经从 FirebaseAuth 获取 user.uid 并将变量传递给 StreamProvider,如果可以获得 user.uid,则返回 StreamProvider。
@override
Widget build(BuildContext context) {
final FirebaseAuthService authService =
Provider.of<FirebaseAuthService>(context, listen: false);
return StreamBuilder<User>(
stream: authService.onAuthStateChanged,
builder: (BuildContext context, AsyncSnapshot<User> snapshot) {
final User loggedInUser = snapshot.data;
if (loggedInUser != null) {
final String userId = loggedInUser.userId;
return MultiProvider(
providers: <SingleChildWidget>[
StreamProvider<User>(
initialData: User.initialData(),
create: (_) => DB.instance.getLoggedInUserStream(
loggedInUserId: userId,
),
Run Code Online (Sandbox Code Playgroud) 我想在发送 FCM 通知后唤醒设备。我能够使用 Cloud Functions 中的 admin sdk 向 Android 设备发送通知。但是,我无法在锁定时唤醒设备(仅发出声音)。其他应用程序(例如 Gmai)可以唤醒设备。此外,它在 iOS 上运行良好。
以下是云函数中的代码。
try {
const options = {
priority: "high",
};
const payload: admin.messaging.MessagingPayload = {
notification: {
title: message.title,
body: message.body,
click_action: 'FLUTTER_NOTIFICATION_CLICK',
badge: `${message.badgeNum}`,
},
};
await admin.messaging().sendToDevice(message.fcmToken, payload, options);
} catch (e) {
console.error(e.message);
throw e;
}
Run Code Online (Sandbox Code Playgroud) 我想创建一个没有完全控制的屏幕共享应用程序(iOS / Android)。只需共享他们的屏幕,就像 Skype 中的屏幕共享一样。
有谁知道如何使用 flutter 进行屏幕共享?我必须使用本机代码吗?或者我可以使用agora.io SDK来实现此目的吗?
谢谢!