我们需要每天早上7点运行重复通知,并且内容不是静态的,而是动态的
内容需要从API获取
有什么办法可以在ios和android中快速实现
没有从服务器端做任何事情?
我们使用了https://pub.dev/packages/flutter_local_notifications并没有解决问题?
我们正在为现有网站开发应用程序,客户拥有所有API,并且他们未使用FCM。他们不会在服务器端进行任何更改,因此强烈建议仅从应用程序端进行处理。
如果我们使用Firebase消息传递库,是否可以在ios和android应用程序中在后台进行通知和API调用?
最佳答案
将firebase函数与pubsub一起使用。在firebase函数中使用此代码。
const admin = require('firebase-admin');
const fcm = admin.messaging();
exports.dailyNotification = functions.pubsub.schedule('0 7 * * *')
.onRun((context) => {
//tokens need to be unique to send notifications per device
//you can call data from firebase firestore to change the notification contents
const payload = admin.messaging.MessagingPayload = {
notification: {
title: 'Notification title',
body: 'This is a notification message',
icon: 'your-icon-url',
click_action: 'FLUTTER_NOTIFICATION_CLICK'
}
};
/*this token you need to save from flutter. You need it only when you
need to send specific notification to the specific device*/
fcm.sendToDevice(tokens.token, payload);
});
flutter 地使用这个包Firebase messaging lib
从此处了解如何使用Firebase消息通知。
Flutter firebase notification tutorial
如果您有任何问题,请告诉我。
关于android - 我们需要每天早上7点运行重复通知,内容是动态的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63375616/