I tried to use custom action from James No Code (the code bellow). But this custom has dependency awesome_notifications: ^0.8.2. It is not for iOS. Android app works normally.
It occurs a huge issue to deploy in AppStore.
// Automatic FlutterFlow imports
import '/backend/schema/structs/index.dart';
import '/backend/schema/enums/enums.dart';
import '/backend/supabase/supabase.dart';
import '/actions/actions.dart' as action_blocks;
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:awesome_notifications/awesome_notifications.dart';
Future initializeMessaging() async {
// Add your function code here!
await Firebase.initializeApp();
FirebaseMessaging.instance.requestPermission().then((settings) {
if (settings.authorizationStatus == AuthorizationStatus.authorized) {
FirebaseMessaging.instance.getToken().then((token) {
// Assuming FFAppState is a singleton or has been instantiated elsewhere appropriately.
// Update the FCM token in your app's state.
FFAppState().fcmToken = token ?? 'No token';
});
} else {
// Handle the case where permission is not granted.
FFAppState().fcmToken = 'No token';
}
});
// Initialize our local notifications
await AwesomeNotifications().initialize(
null, //'resource://drawable/res_app_icon',//
[
NotificationChannel(
channelKey: 'alerts',
channelName: 'Alerts',
channelDescription: 'Notification tests as alerts',
playSound: true,
onlyAlertOnce: true,
groupAlertBehavior: GroupAlertBehavior.Children,
importance: NotificationImportance.High,
defaultPrivacy: NotificationPrivacy.Private,
defaultColor: Colors.deepPurple,
ledColor: Colors.deepPurple)
],
debug: true);
FirebaseMessaging.onMessage.listen((RemoteMessage message) async {
// Assuming you have a method to display notifications or update UI:
// showNotification(message.notification?.title, message.notification?.body);
print('received message 1: ${message.notification?.title}');
await AwesomeNotifications().createNotification(
content: NotificationContent(
id: -1, // -1 is replaced by a random number
channelKey: 'alerts',
title: message.notification?.title ?? 'No title',
body: message.notification?.body ??
'No body', // 'Hello! How are you?',
// bigPicture: 'https://storage.googleapis.com/cms-storage-bucket/d406c736e7c4c57f5f61.png',
// largeIcon: 'https://storage.googleapis.com/cms-storage-bucket/0dbfcc7a59cd1cf16282.png',
//'asset://assets/images/balloons-in-sky.jpg',
// notificationLayout: NotificationLayout.BigPicture,
payload: {'notificationId': '1234567890'}),
actionButtons: [
NotificationActionButton(
key: 'DISMISS',
label: 'Dismiss',
actionType: ActionType.DismissAction,
isDangerousOption: true)
]);
});
}
I tried replace old version awesome_notifications 0.8.2 on the latest version 0.9.3. The app doesn't work fully. I tested on Android. A white screen appears on app loading and I can do nothing.
Did you check FlutterFlow's Documentation for this topic?