Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[firebase_messaging] FCM messaging using Flutter does not work on iPhone, but it works fine on Android device #2885

Closed
ghost opened this issue Jul 2, 2020 · 11 comments
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. closed-by-bot Stale Issue with no recent activity

Comments

@ghost
Copy link

ghost commented Jul 2, 2020

I built the flutter live_chat app using plugin "firebase_messaging: ^5.1.8". The app uses topic notification for the live chatting. it works fine on android devices but does not work on iphones. if the sender sends the notification to ipone device ( or from cloud messaging in firebase project sends the notification), the receiver can see the push notification in his iphone device but the callback function in app to receive the notification does not work. I upgraded the version of "firebase-messaging" plugin from "^5.1.8" to "^6.0.9" but the issue is same.

The following is the main class for FCM messaging.

FCMManager() {
    _firebaseMessaging = FirebaseMessaging();


    _firebaseMessaging.configure(
      onMessage: (Map<String, dynamic> message) async {
      
          SoundManager.getInstance().playNewMessageSound();
      
          Map data;
      
          if(Platform.isIOS) {
            data = message;
          } else {
            data = message['data'] as Map;
          }
          
          if(data['type'] == 'notification') {
       
            DashboardScreen.getInstance().increaseUnreadNotificationCount(1);
       
            String notificationData = data['data'] as String;
            Map notificationJsonMap = json.decode(notificationData) as Map;
            SchoolNotification newNotification = SchoolNotification.fromJson(notificationJsonMap);
            if(_notificationReceivedCallback != null) {
              _notificationReceivedCallback(newNotification);
            }
          } else if (data['type'] == 'message') {
            String messageData = data['data'] as String;
            Map messageJsonMap = json.decode(messageData) as Map;
            Message newMessage = Message.fromJson(messageJsonMap);
        
            if(newMessage.senderId == SessionManager.getUserID()) return;
        
            if(_messageRecievedOnChatRoomCallback != null && SessionManager.getCurrentChatRoomID() == 
newMessage.classId) {
              _messageRecievedOnChatRoomCallback(newMessage);
            } else {
              DashboardScreen.getInstance().increaseUnreadMessageCount(1);
              if(_messageReceivedCallback != null) {
                _messageReceivedCallback(newMessage);
              }
            }
          } else if(data['type'] == 'school_status') {
            var _status = data['value'];
            int status = -1;

            if(_status is int) {
              status = _status;
            } else if(_status is String) {
              status = int.parse(_status);
            }
            if(status == -1) {
              return;
            }
            if(_activationCallback != null) {
              _activationCallback(status);
            }
          }
      },
    );
     _firebaseMessaging.requestNotificationPermissions(
        const IosNotificationSettings(
            sound: true, badge: true, alert: true));
    _firebaseMessaging.onIosSettingsRegistered
        .listen((IosNotificationSettings settings) {
      //print("Settings registered: $settings");
    });

    _firebaseMessaging.onTokenRefresh.listen((token) {
      if(_onTokenRefresh != null) {
        _onTokenRefresh(token);
      }
    });
  }

  void subscribe({SubscribeCallback onSubscribe}) {
    if(onSubscribe != null) {
      onSubscribe(_firebaseMessaging);
    }
  }

  void unSubscribe({UnsubscribeCallback onUnsubscribe}) {
    if(onUnsubscribe != null) {
      onUnsubscribe(_firebaseMessaging);
    } 
  }

  void setTokenRefreshCallback(FCMTokenRefreshCallback callback) {
    this._onTokenRefresh = callback;
  }

  void setNotificationReceivedCallback(NotificationReceivedCallback callback) {
    this._notificationReceivedCallback = callback;
  }

  void setMessageReceivedCallback(MessageReceivedCallback callback) {
    this._messageReceivedCallback = callback;
  }

  void setChatRoomMessageReceivedCallback(MessageRecievedOnChatRoomCallback callback) {
    this._messageRecievedOnChatRoomCallback = callback;
  }

  void setActivationCallback(SchoolActivationCallback callback) {
    this._activationCallback = callback;
  }
}

Flutter doctor

MISs-Mac:myschoolapp_frontend mis$ flutter doctor -v 
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.14.4 18E226, locale en-AF) • Flutter version 1.12.13+hotfix.8 at /Users/mis/Desktop/flutter • Framework revision 0b8abb4724 (4 months ago), 2020-02-11 11:44:36 -0800 • Engine revision e1e6ced81d • Dart version 2.7.0

[✗] Android toolchain - develop for Android devices ✗ Unable to locate Android SDK. Install Android Studio from: https://developer.android.com/studio/index.html On first launch it will assist you in installing the Android SDK components. (or visit https://flutter.dev/setup/#android-setup for detailed instructions). If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location. You may also want to add it to your PATH environment variable.

[✓] Xcode - develop for iOS and macOS (Xcode 11.0) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.0, Build version 11A420a • CocoaPods version 1.8.4

[!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/setup/#android-setup for detailed instructions).

[✓] VS Code (version 1.43.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.9.1

[!] Connected device ! No devices available

Please help me from this issue.

Best Regards

@ghost ghost changed the title [<firebase_messaging>] <FCM messaging using Flutter does not work on iPhone, but it works fine on Android device> [firebase_messaging] FCM messaging using Flutter does not work on iPhone, but it works fine on Android device Jul 2, 2020
@TahaTesser
Copy link

Hi @kingdragon2108
When app is in background and user clicks on notification to open the app, you can put onResume is called

flutter: onResume: {status: done, google.c.sender.id: 486685679562, google.c.a.e: 1, id: 1, aps: {alert: {title: this is a title, body: this is a body}}, gcm.message_id: 1593772583866189, click_action: FLUTTER_NOTIFICATION_CLICK}

flutter: onResume: {status: done, google.c.sender.id: 486685679562, google.c.a.e: 1, id: 1, aps: {alert: {title: this is a title, body: this is a body}}, gcm.message_id: 1593772583866189, click_action: FLUTTER_NOTIFICATION_CLICK}

When app is in foreground, it will call onMessage

    onMessage: (Map<String, dynamic> message) async {
        print("onMessage: $message");
        _showItemDialog(message);
      },
flutter: onMessage: {status: done, google.c.sender.id: 486685679562, google.c.a.e: 1, id: 1, aps: {alert: {title: this is a title, body: this is a body}}, gcm.message_id: 1593772659532809, click_action: FLUTTER_NOTIFICATION_CLICK}

You should move your log into onResume
Please test this code sample

Code Sample
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';

Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) {
  if (message.containsKey('data')) {
    // Handle data message
    final dynamic data = message['data'];
  }

  if (message.containsKey('notification')) {
    // Handle notification message
    final dynamic notification = message['notification'];
  }

  // Or do other work.
}

final Map<String, Item> _items = <String, Item>{};
Item _itemForMessage(Map<String, dynamic> message) {
  final dynamic data = message['data'] ?? message;
  final String itemId = data['id'];
  final Item item = _items.putIfAbsent(itemId, () => Item(itemId: itemId))
    ..status = data['status'];
  return item;
}

class Item {
  Item({this.itemId});
  final String itemId;

  StreamController<Item> _controller = StreamController<Item>.broadcast();
  Stream<Item> get onChanged => _controller.stream;

  String _status;
  String get status => _status;
  set status(String value) {
    _status = value;
    _controller.add(this);
  }

  static final Map<String, Route<void>> routes = <String, Route<void>>{};
  Route<void> get route {
    final String routeName = '/detail/$itemId';
    return routes.putIfAbsent(
      routeName,
      () => MaterialPageRoute<void>(
        settings: RouteSettings(name: routeName),
        builder: (BuildContext context) => DetailPage(itemId),
      ),
    );
  }
}

class DetailPage extends StatefulWidget {
  DetailPage(this.itemId);
  final String itemId;
  @override
  _DetailPageState createState() => _DetailPageState();
}

class _DetailPageState extends State<DetailPage> {
  Item _item;
  StreamSubscription<Item> _subscription;

  @override
  void initState() {
    super.initState();
    _item = _items[widget.itemId];
    _subscription = _item.onChanged.listen((Item item) {
      if (!mounted) {
        _subscription.cancel();
      } else {
        setState(() {
          _item = item;
        });
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Item ${_item.itemId}"),
      ),
      body: Material(
        child: Center(child: Text("Item status: ${_item.status}")),
      ),
    );
  }
}

class PushMessagingExample extends StatefulWidget {
  @override
  _PushMessagingExampleState createState() => _PushMessagingExampleState();
}

class _PushMessagingExampleState extends State<PushMessagingExample> {
  String _homeScreenText = "Waiting for token...";
  bool _topicButtonsDisabled = false;

  final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
  final TextEditingController _topicController =
      TextEditingController(text: 'topic');

  Widget _buildDialog(BuildContext context, Item item) {
    return AlertDialog(
      content: Text("Item ${item.itemId} has been updated"),
      actions: <Widget>[
        FlatButton(
          child: const Text('CLOSE'),
          onPressed: () {
            Navigator.pop(context, false);
          },
        ),
        FlatButton(
          child: const Text('SHOW'),
          onPressed: () {
            Navigator.pop(context, true);
          },
        ),
      ],
    );
  }

  void _showItemDialog(Map<String, dynamic> message) {
    showDialog<bool>(
      context: context,
      builder: (_) => _buildDialog(context, _itemForMessage(message)),
    ).then((bool shouldNavigate) {
      if (shouldNavigate == true) {
        _navigateToItemDetail(message);
      }
    });
  }

  void _navigateToItemDetail(Map<String, dynamic> message) {
    final Item item = _itemForMessage(message);
    // Clear away dialogs
    Navigator.popUntil(context, (Route<dynamic> route) => route is PageRoute);
    if (!item.route.isCurrent) {
      Navigator.push(context, item.route);
    }
  }

  @override
  void initState() {
    super.initState();
    _firebaseMessaging.configure(
      onMessage: (Map<String, dynamic> message) async {
        print("onMessage: $message");
        _showItemDialog(message);
      },
      onBackgroundMessage: myBackgroundMessageHandler,
      onLaunch: (Map<String, dynamic> message) async {
        print("onLaunch: $message");
        _navigateToItemDetail(message);
      },
      onResume: (Map<String, dynamic> message) async {
        print("onResume: $message");
        _navigateToItemDetail(message);
      },
    );
    _firebaseMessaging.requestNotificationPermissions(
        const IosNotificationSettings(
            sound: true, badge: true, alert: true, provisional: true));
    _firebaseMessaging.onIosSettingsRegistered
        .listen((IosNotificationSettings settings) {
      print("Settings registered: $settings");
    });
    _firebaseMessaging.getToken().then((String token) {
      assert(token != null);
      setState(() {
        _homeScreenText = "Push Messaging token: $token";
      });
      print(_homeScreenText);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('Push Messaging Demo'),
        ),
        // For testing -- simulate a message being received
        floatingActionButton: FloatingActionButton(
          onPressed: () => _showItemDialog(<String, dynamic>{
            "data": <String, String>{
              "id": "2",
              "status": "out of stock",
            },
          }),
          tooltip: 'Simulate Message',
          child: const Icon(Icons.message),
        ),
        body: Material(
          child: Column(
            children: <Widget>[
              Center(
                child: Text(_homeScreenText),
              ),
              Row(children: <Widget>[
                Expanded(
                  child: TextField(
                      controller: _topicController,
                      onChanged: (String v) {
                        setState(() {
                          _topicButtonsDisabled = v.isEmpty;
                        });
                      }),
                ),
                FlatButton(
                  child: const Text("subscribe"),
                  onPressed: _topicButtonsDisabled
                      ? null
                      : () {
                          _firebaseMessaging
                              .subscribeToTopic(_topicController.text);
                          _clearTopicText();
                        },
                ),
                FlatButton(
                  child: const Text("unsubscribe"),
                  onPressed: _topicButtonsDisabled
                      ? null
                      : () {
                          _firebaseMessaging
                              .unsubscribeFromTopic(_topicController.text);
                          _clearTopicText();
                        },
                ),
              ])
            ],
          ),
        ));
  }

  void _clearTopicText() {
    setState(() {
      _topicController.text = "";
      _topicButtonsDisabled = true;
    });
  }
}

void main() {
  runApp(
    MaterialApp(
      home: PushMessagingExample(),
    ),
  );
}

@TahaTesser TahaTesser added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Jul 3, 2020
@ghost
Copy link
Author

ghost commented Jul 4, 2020

Thanks for your feedback.

I replaced the main.dart file by above sample file and implemented it on two simulators. (the settings in relation to push notification on IOS keeps the same.) I am getting one exception for the firebase_messaging as following:

MISs-Mac:myschoolapp_frontend mis$ flutter run -d all

Launching lib/main.dart on iPhone 8 in debug mode...

Running Xcode build...

├─Assembling Flutter resources... 8.4s
└─Compiling, linking and signing... 24.8s
Xcode build done. 60.9s
path: satisfied (Path is satisfied), interface: en0
Configuring the default Firebase app...
path: satisfied (Path is satisfied), interface: en0
Configured the default Firebase app __FIRAPP_DEFAULT.
Launching lib/main.dart on iPhone 11 in debug mode...
path: satisfied (Path is satisfied), interface: en0
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method FcmDartService#start on channel plugins.flutter.io/firebase_messaging)
#0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7)

#1 FirebaseMessaging.configure (package:firebase_messaging/firebase_messaging.dart:130:16)
#2 _PushMessagingExampleState.initState (package:school_app/main.dart:199:24)
#3 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4355:58)
#4 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
#5 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#6 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
#7 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
#8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#9 Element<…>
flutter: Settings registered: PushNotificationSettings {sound: true, alert: true, badge: true, provisional: true}
flutter: Push Messaging token: eA3evd4fg2M:APA91bHbQI8CiZ0lP2sz4N1jvXMpva8VVGoXl8K_iedL8EQ4S86sqe2kCUggoeOheQsmgKY_GKkn4TIfO-pbNvu_zzDyHMYzcg75-_FSjyjFbjixvKdLqz-NyZMFLnwhD1EWswFgVSfN

Running Xcode build...

├─Assembling Flutter resources... 5.7s
└─Compiling, linking and signing... 18.7s
Xcode build done. 41.0s
path: satisfied (Path is satisfied), interface: en0
Configuring the default Firebase app...
path: satisfied (Path is satisfied), interface: en0
Configured the default Firebase app __FIRAPP_DEFAULT.
path: satisfied (Path is satisfied), interface: en0
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method FcmDartService#start on channel plugins.flutter.io/firebase_messaging)
#0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7)

#1 FirebaseMessaging.configure (package:firebase_messaging/firebase_messaging.dart:130:16)
#2 _PushMessagingExampleState.initState (package:school_app/main.dart:199:24)
#3 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4355:58)
#4 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
#5 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#6 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
#7 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
#8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
#9 Element<…>
flutter: Settings registered: PushNotificationSettings {sound: false, alert: false, badge: false, provisional: true}
flutter: Push Messaging token: dKl9MDS_7EtQq929uCTz03:APA91bF3fvNz4Yp8HKJfXEoPIJQelzCN9DAKwiitKg597dkDcqt3yXVtOFxYAEWcS44XgO3HFqkI07FhfdXUqIljlIMvpldtqTeUgDakYwrG5yNhzKJMEWYqo5zrGshHz0adW_xmluYP
Syncing files to device iPhone 8...
9,064ms (!)
Syncing files to device iPhone 11...

  1. After i click "subscribe" button, if i click the detail button (in bottom of the page) and click "SHOW" in alert dialog, i get the following error screen.

2020-07-04_12h41_06

  1. I sent the topic notification( with title "topic" ) from the cloud messaging of the ios project on firebase console but callback functions (onMessage, onBackgroundMessage, onResume) don't receive anything.

I can't make sure whether the sample codes works fine or not.
Please give me the guide.

@TahaTesser
Copy link

Hi @kingdragon2108

This is because of configuration problem, please add your plist file from firebse and add firebase in your /AppDelegate.swift

[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method FcmDartService#start on channel plugins.flutter.io/firebase_messaging)
#0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7)

import UIKit
import Flutter
import Firebase

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    if #available(iOS 10.0, *) {
      UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
    }
    FirebaseApp.configure()
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

and many more things to add to make it proeprly pleae check https://pub.dev/packages/firebase_messaging#ios-integration
Thank you

@TahaTesser TahaTesser added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Jul 6, 2020
@ghost
Copy link
Author

ghost commented Jul 10, 2020

Hello Tesser

Thank you for your reply. Before few months I added the GoogleService-info.plist to project and today i added firebace to AppDelegate.swift. Then the App is crashed. So i am going to share the project codes with you.
I will appreciate to you if you let me know your email address or skype id.

Best Regards

@TahaTesser TahaTesser removed the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Jul 10, 2020
@TahaTesser
Copy link

@kingdragon2108
Hi., please create a new project and follow the steps and try to reproduce issue
You can share minimal code sample in a repository, remove confidential data from your code, no need to. include GoogleService-info.plist
Thank you

@TahaTesser TahaTesser added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Jul 10, 2020
@saravananmnm
Copy link

`void initialize() async {
AndroidInitializationSettings android = new AndroidInitializationSettings(
'@mipmap/ic_launcher'); //@mipmap/ic_launcher
IOSInitializationSettings ios = new IOSInitializationSettings(
onDidReceiveLocalNotification: onDidReceiveLocalNotification);
var initSettings = new InitializationSettings(android, ios);
flutterLocalNotificationsPlugin =
new FlutterLocalNotificationsPlugin();
flutterLocalNotificationsPlugin.initialize(initSettings);
/flutterLocalNotificationsPlugin.initialize(initSettings,
onSelectNotification: onSelectNotification);
/
firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(sound: true, alert: true, badge: true));
firebaseMessaging.onIosSettingsRegistered
.listen((IosNotificationSettings setting) {
print('IOS Setting Registed');
});
showNotification();
}

showNotification() async {
var androidPlatformChannelSpecifies = new AndroidNotificationDetails(
"CA", "Courier Alliance", "Courier Alliance",
importance: Importance.Max,
groupKey: 'iex',
groupAlertBehavior: GroupAlertBehavior.All,
priority: Priority.High,
color: Colors.blue,
autoCancel: true,
styleInformation: BigTextStyleInformation(''),
largeIcon: DrawableResourceAndroidBitmap('@mipmap/ic_launcher'),
icon: '@mipmap/ic_launcher',
playSound: true,
sound: RawResourceAndroidNotificationSound('new_auction_notification'));
var iOSPlatformChannelSpecifics =
new IOSNotificationDetails(presentAlert: true, presentSound: true);
var platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifies, iOSPlatformChannelSpecifics);
firebaseMessaging.configure(
onLaunch: (Map<String, dynamic> msg) {
print(" onLaunch called ${(msg)}");
},
onResume: (Map<String, dynamic> msg) {
print(" onResume called ${(msg)}");
},
onMessage: (Map<String, dynamic> msg) async {
widget.notificationListener.onNotify();
// notifyCount.sink.add(count);
print(" onMessage called ${msg}");
String val = '';
val = msg['data']['message'];
await flutterLocalNotificationsPlugin.show(
0, 'Courier Alliance', val, platformChannelSpecifics,
payload: 'CA');
print('Displayed :${DateTime.now().millisecond}');
},
onBackgroundMessage: myBackgroundMessageHandler);
}

Future onDidReceiveLocalNotification(
int id, String title, String body, String payload) async {
return showDialog(
context: context,
builder: (BuildContext context) => new CupertinoAlertDialog(
title: new Text(title),
content: new Text(body),
actions: [
CupertinoDialogAction(
isDefaultAction: true,
child: new Text('Ok'),
onPressed: () async {
Navigator.of(context, rootNavigator: true).pop();
},
)
],
),
);
}
}

Future myBackgroundMessageHandler(Map<String, dynamic> message) async {
FirebaseMessaging firebaseMessaging = new FirebaseMessaging();
AndroidInitializationSettings android = new AndroidInitializationSettings(
'@mipmap/ic_launcher'); //@mipmap/ic_launcher
IOSInitializationSettings ios = new IOSInitializationSettings(
onDidReceiveLocalNotification: onDidReceiveLocalNotification);
var initSettings = new InitializationSettings(android, ios);
var flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
flutterLocalNotificationsPlugin.initialize(initSettings);
firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(sound: true, alert: true, badge: true));

String val = message['data']['message'];
print('');
print('FireBase Notification Came');
print('
');
print('${val}');

var androidPlatformChannelSpecifies = new AndroidNotificationDetails(
"CA", "Courier Alliance", "Courier Alliance",
importance: Importance.Max,
groupKey: 'iex',
groupAlertBehavior: GroupAlertBehavior.All,
priority: Priority.High,
color: Colors.blue,channelShowBadge: true,
autoCancel: true,
styleInformation: BigTextStyleInformation(''),
largeIcon: DrawableResourceAndroidBitmap('@mipmap/ic_launcher'),
icon: '@mipmap/ic_launcher',
playSound: true,
sound: RawResourceAndroidNotificationSound('new_auction_notification'));
var iOSPlatformChannelSpecifics =
new IOSNotificationDetails(presentAlert: true, presentSound: true);
var platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifies, iOSPlatformChannelSpecifics);

await flutterLocalNotificationsPlugin.show(
0, 'Courier Alliance', val, platformChannelSpecifics,
payload: 'CA');
return Future.value(flutterLocalNotificationsPlugin);
}

Future onDidReceiveLocalNotification(
int id, String title, String body, String payload) async {
/showDialog(
context: mContext,
builder: (BuildContext context) => new CupertinoAlertDialog(
title: new Text(title),
content: new Text(body),
actions: [
CupertinoDialogAction(
isDefaultAction: true,
child: new Text('Ok'),
onPressed: () async {
Navigator.of(context, rootNavigator: true).pop();
},
)
],
),
);
/
}`

@saravananmnm
Copy link

Try this for background messaging. This is works for me.

@google-oss-bot
Copy link

Hey @kingdragon2108. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@google-oss-bot google-oss-bot added the Stale Issue with no recent activity label Jul 30, 2020
@google-oss-bot
Copy link

Since there haven't been any recent updates here, I am going to close this issue.

@kingdragon2108 if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

@Doetheman
Copy link

FCM works in the background of my app. I followed the documentation to integrate firebase messageing. See my flutter version below. When I test on a simulator, I get all notifications. What could be the issue?

[✓] Flutter (Channel stable, 1.20.2, on Mac OS X 10.15.4 19E266, locale en-CA)

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
✗ Android licenses not accepted. To resolve this, run: flutter doctor
--android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
[✓] Android Studio (version 4.0)
[✓] Connected device (1 available)

@TahaTesser
Copy link

Could everyone who still has this problem please file a new issue with the exact description of what happens, logs and the output of flutter doctor -v.
All system setups can be slightly different, so it's always better to open new issues and reference related issues.

@firebase firebase locked and limited conversation to collaborators Sep 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. closed-by-bot Stale Issue with no recent activity
Projects
None yet
Development

No branches or pull requests

4 participants