android - 我们需要每天早上7点运行重复通知,内容是动态的

标签 android ios flutter dart flutter-dependencies

我们需要每天早上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/

相关文章:

android - 灯箱与移动设备不兼容

Android M 奇怪的共享偏好问题

ios - 在 iTunes connect 上线前更改版本

android-studio - 当尝试 flutter 的 Widget 时,抛出 NoSuchMethodError 说 The method '_debugTypesAreRight' was called on null

flutter - 如何从右上角而不是左上角启动CustomClipper(ClipPath)

android - 我移动时如何绘制根路径?

android - 在不滚动的情况下打开 ViewPager2 到特定位置

ios - OPENCV iOS安装

ios - 如何在 Storyboard 中将标签栏与其 View Controller 链接起来?

android - flutter android指纹集成