Skip to content

🐛 [firebase_messaging] No longer receiving data messages in FOREGROUND on iOS #3735

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

Closed
rubenvereecken opened this issue Oct 1, 2020 · 9 comments · Fixed by #4012
Closed
Labels
Needs Attention This issue needs maintainer attention. type: bug Something isn't working

Comments

@rubenvereecken
Copy link

rubenvereecken commented Oct 1, 2020

Bug report

Describe the bug
The onMessage handler is no longer called for data messages on iOS in the foreground. It is called for data messages on Android in the foreground, and it is called for display messages on iOS in the foreground.

Steps to reproduce

Steps to reproduce the behavior:

  1. Set up onMessage handler in the app
  2. Send a simple data message to an iOS registration token
  3. ... Wait
  4. See it never get called

Expected behavior

I would expect the onMessage handler to be called for data messages in the foreground. This is supposed to be the simple scenario. This used to work.


Additional context

I have tried different data messages to see if my format is the culprit, to see if something's changed. To no avail (and note that they still work fine for Android).

Here is what I would normally send (no longer works - just iOS in foreground though):

{
  "data": {
    "type": "friend-request:cancelled",
    "action": "deleted",
    "collection": "incoming-friend-requests",
    "userId": "tr5EajFZpubvNypZxAGc3SnykWc2"
  },
  "android": {
    "priority": "normal"
  }
}

(EDIT) I just saw this pop up in XCode whenever I would send a data message and I could not figure out how it's related but I suppose it must be.

2020-10-01 15:58:24.788526+0100 Runner[972:925222] Warning: Application delegate received call to -application:didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called.

I figured this was related to these lines in AppDelegate.swift.

    if #available(iOS 10.0, *) {
      UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
    }

Yet when I removed these, I no longer received display messages (notifications) in the foreground either. So those lines are working.. but only for display messages. Something is holding back my data messages.

I have also tried to add content_available to aps but no luck.

The fact that it's worked before and I do still get display messages (notifications) in the onMessage handler with the app open in the foreground makes me think it can't be a configuration issue on my part.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
[✓] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.6 19G2021, locale en-GB)
 
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.49.1)
[!] Connected device

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
Dart SDK 2.9.2
Flutter SDK 1.20.4

dependencies:
- apple_sign_in 0.1.0 [flutter]
- auto_size_text 2.1.0 [flutter]
- cached_network_image 2.3.2+1 [flutter flutter_cache_manager octo_image]
- cupertino_icons 1.0.0
- dio 3.0.10 [http_parser path]
- dio_retry 0.1.9-beta [meta logging dio]
- equatable 1.2.5 [collection meta]
- firebase_analytics 6.0.0 [meta flutter firebase_core firebase_analytics_web firebase_analytics_platform_interface]
- firebase_auth 0.18.0+1 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter]
- firebase_core 0.5.0 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_dynamic_links 0.6.0 [flutter firebase_core]
- firebase_messaging 7.0.0 [meta platform flutter firebase_core]
- firebase_remote_config 0.4.0 [flutter firebase_core]
- flare_splash_screen 3.0.1 [flare_loading flutter]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_facebook_login 3.0.0 [flutter collection]
- flutter_linkify 3.1.3 [flutter linkify]
- flutter_markdown 0.4.4 [flutter markdown meta path]
- flutter_native_timezone 1.0.4 [flutter]
- flutter_portal 0.1.0 [flutter]
- flutter_signin_button 1.1.0 [flutter font_awesome_flutter]
- flutter_speed_dial 1.2.5 [flutter]
- font_awesome_flutter 8.8.1 [flutter]
- google_maps_flutter 0.5.32 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface]
- google_sign_in 4.5.3 [google_sign_in_platform_interface flutter meta google_sign_in_web]
- horizontal_blocked_scroll_physics 3.0.0 [flutter pedantic]
- image_cropper 1.3.1 [flutter]
- image_picker 0.6.7+7 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- in_app_update 1.1.11 [flutter]
- intl 0.16.1 [path]
- introduction_screen 1.0.9 [flutter dots_indicator]
- jiffy 3.0.1 [intl]
- location 3.0.2 [flutter meta location_platform_interface location_web]
- maps_launcher 1.2.2+1 [flutter flutter_web_plugins url_launcher]
- open_appstore 1.0.2 [flutter]
- package_info 0.4.3 [flutter]
- provider 4.3.2+2 [flutter nested collection]
- pub_semver 1.4.4 [collection]
- pull_to_refresh 1.6.1 [flutter]
- quiver 2.1.3 [matcher meta]
- rxdart 0.24.1
- share 0.6.5 [meta mime flutter]
- shared_preferences 0.5.10 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web]
- stream_chat_flutter 0.2.8+2 [flutter photo_view rxdart jiffy flutter_portal cached_network_image flutter_markdown url_launcher video_player chewie file_picker image_picker flutter_keyboard_visibility stream_chat mime visibility_detector http_parser]
- url_launcher 5.6.0 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]
- validators 2.0.1 [vin_decoder]
- visibility_detector 0.1.5 [flutter]
- workmanager 0.2.3 [flutter]

dev dependencies:
- cider 0.0.5 [args change intl markdown marker maybe_just_nothing path pub_semver version_manipulation yaml yaml_edit]
- flutter_driver 0.0.0 [file json_rpc_2 meta path web_socket_channel vm_service_client webdriver flutter flutter_test fuchsia_remote_debug_protocol archive args async boolean_selector characters charcode clock collection convert crypto fake_async intl matcher platform process pub_semver source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]
- mockito 4.1.1 [collection matcher meta test_api]
- screenshots 2.1.1 [args yaml resource path file archive platform process meta intl tool_mobile]
- test 1.15.2 [analyzer async boolean_selector coverage http http_multi_server io js node_preamble package_config path pedantic pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel typed_data web_socket_channel webkit_inspection_protocol yaml test_api test_core]

transitive dependencies:
- _fe_analyzer_shared 7.0.0 [meta]
- analyzer 0.39.17 [_fe_analyzer_shared args charcode cli_util collection convert crypto glob html meta package_config path pub_semver source_span watcher yaml]
- archive 2.0.13 [crypto args path]
- args 1.6.0
- asn1lib 0.6.5
- async 2.4.2 [collection]
- basic_utils 2.6.2 [http logging json_annotation pointycastle asn1lib convert crypto]
- boolean_selector 2.0.0 [source_span string_scanner]
- change 0.1.0 [markdown marker maybe_just_nothing pub_semver]
- characters 1.0.0
- charcode 1.1.3
- chewie 0.9.10 [open_iconic_flutter video_player wakelock flutter]
- cli_util 0.2.0 [path]
- clock 1.0.1 [meta]
- collection 1.14.13
- convert 2.1.1 [charcode typed_data]
- coverage 0.14.1 [args logging package_config path source_maps stack_trace vm_service]
- crypto 2.1.5 [collection convert typed_data]
- csslib 0.16.2 [source_span]
- dots_indicator 1.2.0 [flutter]
- fake_async 1.1.0 [clock collection]
- ffi 0.1.3
- file 5.2.1 [intl meta path]
- file_picker 2.0.6 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface]
- firebase 7.3.0 [http http_parser js]
- firebase_analytics_platform_interface 1.0.3 [flutter meta]
- firebase_analytics_web 0.1.1 [flutter flutter_web_plugins firebase firebase_analytics_platform_interface meta]
- firebase_auth_platform_interface 2.0.1 [flutter meta firebase_core plugin_platform_interface]
- firebase_auth_web 0.3.0+1 [flutter flutter_web_plugins firebase meta http_parser intl firebase_core firebase_auth_platform_interface js]
- firebase_core_platform_interface 2.0.0 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.0 [firebase firebase_core_platform_interface flutter flutter_web_plugins meta js]
- flare_dart 2.3.4
- flare_flutter 2.0.6 [flutter flare_dart meta]
- flare_loading 2.1.1 [flare_flutter flutter]
- flutter_blurhash 0.5.0 [flutter meta]
- flutter_cache_manager 1.4.2 [flutter path_provider uuid http path sqflite pedantic clock file rxdart]
- flutter_keyboard_visibility 3.2.2 [flutter]
- flutter_plugin_android_lifecycle 1.0.9 [flutter]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- fuchsia_remote_debug_protocol 0.0.0 [json_rpc_2 process web_socket_channel flutter_test flutter_driver archive args async boolean_selector charcode clock collection convert crypto fake_async file intl matcher meta path platform pub_semver source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math vm_service_client webdriver]
- glob 1.2.0 [async collection node_io path pedantic string_scanner]
- google_maps_flutter_platform_interface 1.0.4 [flutter meta plugin_platform_interface stream_transform]
- google_sign_in_platform_interface 1.1.2 [flutter meta quiver]
- google_sign_in_web 0.9.2 [google_sign_in_platform_interface flutter flutter_web_plugins meta js]
- html 0.14.0+3 [csslib source_span]
- http 0.12.2 [http_parser path pedantic]
- http_multi_server 2.2.0 [async]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- image_picker_platform_interface 1.1.0 [flutter meta http plugin_platform_interface]
- io 0.3.4 [charcode meta path string_scanner]
- js 0.6.2
- json_annotation 3.0.1
- json_rpc_2 2.2.1 [stack_trace stream_channel]
- linkify 2.1.0
- location_platform_interface 1.0.0 [flutter meta plugin_platform_interface]
- location_web 1.0.0 [flutter flutter_web_plugins location_platform_interface http_parser meta js]
- logging 0.11.4
- markdown 2.1.8 [args charcode meta]
- marker 0.1.0 [markdown]
- matcher 0.12.8 [stack_trace]
- maybe_just_nothing 0.3.1
- meta 1.1.8
- mime 0.9.7
- moor 3.3.1 [meta convert collection synchronized pedantic sqlite3]
- nested 0.0.4 [flutter]
- node_interop 1.1.1 [js]
- node_io 1.1.1 [node_interop path]
- node_preamble 1.4.12
- octo_image 0.3.0 [flutter flutter_blurhash]
- open_iconic_flutter 0.3.0 [flutter]
- package_config 1.9.3 [path charcode]
- path 1.7.0
- path_provider 1.6.14 [flutter path_provider_platform_interface path_provider_macos path_provider_linux]
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 0.0.4+3 [flutter]
- path_provider_platform_interface 1.0.3 [flutter meta platform plugin_platform_interface]
- pedantic 1.9.0
- photo_view 0.10.2 [flutter]
- platform 2.2.1
- platform_detect 1.4.0 [meta pub_semver]
- plugin_platform_interface 1.0.2 [meta]
- pointycastle 1.0.2
- pool 1.4.0 [async stack_trace]
- process 3.0.13 [file intl meta path platform]
- pub_cache 0.2.3 [path pub_semver yaml]
- random_string 2.1.0
- resource 2.1.7 [typed_data]
- shared_preferences_linux 0.0.2+2 [file flutter meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 0.0.1+10 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 1.0.4 [meta flutter]
- shared_preferences_web 0.1.2+7 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- shelf 0.7.9 [async collection http_parser path stack_trace stream_channel]
- shelf_packages_handler 2.0.0 [path shelf shelf_static]
- shelf_static 0.2.8 [convert http_parser mime path shelf]
- shelf_web_socket 0.2.3 [shelf web_socket_channel stream_channel]
- sky_engine 0.0.99
- source_map_stack_trace 2.0.0 [path stack_trace source_maps]
- source_maps 0.10.9 [source_span]
- source_span 1.7.0 [charcode collection meta path term_glyph]
- sqflite 1.3.1+1 [flutter sqflite_common path]
- sqflite_common 1.0.2+1 [synchronized path meta]
- sqlite3 0.1.5 [collection ffi meta]
- sqlite3_flutter_libs 0.2.0
- stack_trace 1.9.5 [path]
- stream_channel 2.0.0 [async]
- stream_chat 0.2.5+1 [flutter json_annotation shared_preferences logging dio web_socket_channel uuid async stream_channel moor path_provider path rxdart collection sqlite3_flutter_libs]
- stream_transform 1.2.0
- string_scanner 1.0.5 [charcode meta source_span]
- sync_http 0.2.0
- synchronized 2.2.0+2
- term_glyph 1.1.0
- test_api 0.2.17 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- test_core 0.3.10 [analyzer async args boolean_selector collection coverage glob io meta package_config path pedantic pool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml matcher test_api]
- tool_base 1.9.5+3 [archive file platform process pub_cache]
- tool_mobile 1.9.5+1 [tool_base]
- typed_data 1.2.0 [collection]
- url_launcher_linux 0.0.1+1 [flutter]
- url_launcher_macos 0.0.1+7 [flutter]
- url_launcher_platform_interface 1.0.8 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.3+2 [url_launcher_platform_interface platform_detect flutter flutter_web_plugins meta]
- url_launcher_windows 0.0.1+1 [flutter]
- uuid 2.2.2 [crypto convert]
- vector_math 2.0.8
- version_manipulation 0.0.5 [pub_semver]
- video_player 0.10.12+2 [meta video_player_platform_interface video_player_web flutter]
- video_player_platform_interface 2.1.1 [flutter meta]
- video_player_web 0.1.3+2 [flutter flutter_web_plugins meta video_player_platform_interface]
- vin_decoder 0.1.2 [meta basic_utils http random_string]
- vm_service 4.2.0 [meta]
- vm_service_client 0.2.6+2 [async collection json_rpc_2 pub_semver source_span stack_trace stream_channel web_socket_channel]
- wakelock 0.1.4+2 [flutter]
- watcher 0.9.7+15 [async path pedantic]
- web_socket_channel 1.1.0 [async crypto stream_channel]
- webdriver 2.1.2 [archive matcher path stack_trace sync_http]
- webkit_inspection_protocol 0.7.3 [logging]
- xdg_directories 0.1.0 [path process flutter]
- yaml 2.2.1 [charcode collection string_scanner source_span]
- yaml_edit 1.0.2 [meta yaml source_span collection]

@rubenvereecken rubenvereecken added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Oct 1, 2020
@TahaTesser TahaTesser removed the Needs Attention This issue needs maintainer attention. label Oct 2, 2020
@TahaTesser
Copy link

Hi @rubenvereecken
Pleae try this code sample, no issue son ios with the latest `

flutter doctor -v
[✓] Flutter (Channel stable, 1.22.0, on Mac OS X 10.15.7 19H2, locale en-GB)
    • Flutter version 1.22.0 at /Users/tahatesser/Code/flutter_stable
    • Framework revision d408d302e2 (3 days ago), 2020-09-29 11:49:17 -0700
    • Engine revision 5babba6c4d
    • Dart version 2.10.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/tahatesser/Code/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/tahatesser/Code/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.9.3

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 50.0.1
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

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

[✓] Connected device (1 available)
    • Taha’s iPhone (mobile) • 00008020-001059882212002E • ios • iOS 14.0.1

• No issues found!
`
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_core/firebase_core.dart';
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() async {
  WidgetsFlutterBinding.ensureInitialized();
  FirebaseApp app = await Firebase.initializeApp();
  assert(app != null);
  runApp(
    MaterialApp(
      home: PushMessagingExample(),
    ),
  );
}
  firebase_core: ^0.5.0
  firebase_messaging: ^7.0.2

flutter_01

flutter doctor -v
[✓] Flutter (Channel stable, 1.22.0, on Mac OS X 10.15.7 19H2, locale en-GB)
    • Flutter version 1.22.0 at /Users/tahatesser/Code/flutter_stable
    • Framework revision d408d302e2 (3 days ago), 2020-09-29 11:49:17 -0700
    • Engine revision 5babba6c4d
    • Dart version 2.10.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/tahatesser/Code/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/tahatesser/Code/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.9.3

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 50.0.1
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

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

[✓] Connected device (1 available)
    • Taha’s iPhone (mobile) • 00008020-001059882212002E • ios • iOS 14.0.1

• No issues found!

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

rubenvereecken commented Oct 12, 2020

@TahaTesser Thanks for getting back to me and sorry for taking so long to reply. I wanted to dedicate some proper time to this to properly replicate your example. I've now managed and my problem remains - your example doesn't work for me. I do observe the same I did before: the message enters the device, I get some odd message, but it doesn't reach the message handler. The message I get is the following.

2020-10-12 11:13:27.052179+0100 Runner[385:121125] Warning: Application delegate received call to -
application:didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called.

  firebase_core: ^0.5.0
  firebase_messaging: ^7.0.0

I copied your example ad verbatim. I sent messages using the following curl command which was confirmed to work with display messages but not data messages.

 curl -X POST -H "Authorization:Bearer <access_token>" -H "Content-Type: application/json" -d '{
  "message":{
    "token":"<token I grabbed from the device's logs>",
    "data":{
      "id":"3",
      "status":"This be a test"
    }
  }
}' https://fcm.googleapis.com/v1/projects/<firebase-project>/messages:send

My worry is that I set up something else incorrectly but I can't for the life of me think of what else has changed because this definitely used to work. Something I feel insecure about for example is AppDelegate.swift, as I mentioned in the initial post. What else can I verify? The APNS config all seems right otherwise I wouldn't be getting display messages.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Oct 12, 2020
@TahaTesser TahaTesser removed the Needs Attention This issue needs maintainer attention. label Oct 14, 2020
@TahaTesser
Copy link

Hi @rubenvereecken
The example I used is official example, can you please try in a project on the same firebase account
Using this payload

const payload = {
    'notification': {
        'title': 'this is a title',
        'body': 'this is a body',

    },
    'data': {
        'click_action': 'FLUTTER_NOTIFICATION_CLICK',
        'id': '1',
        'status': 'done'
    }
};

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

@TahaTesser That is a display message because it has a notification property and as I said those work fine. This problem is about data messages. Please look at the error message I reported above (I'll replicate it here)

2020-10-12 11:13:27.052179+0100 Runner[385:121125] Warning: Application delegate received call to -
application:didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Oct 14, 2020
@rubenvereecken
Copy link
Author

I'm sure the warning message contains some useful indication but I'm not experienced enough with iOS to interpret it.

@TahaTesser TahaTesser removed the Needs Attention This issue needs maintainer attention. label Oct 16, 2020
@TahaTesser
Copy link

Hi @rubenvereecken
Can you please a complete reproducible minimal code sample in a repository?
Thank you

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

I now understand this appears to be a duplicate of #3395 which is still open.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Oct 17, 2020
@TahaTesser
Copy link

hI @rubenvereecken
So you have been sending data only messages? As mentioned I tested with a complete payload
Thanks for finding the duplicate
Closing as duplicate of #3395

@rubenvereecken
Copy link
Author

As per the title, yep.

@firebase firebase locked and limited conversation to collaborators Nov 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs Attention This issue needs maintainer attention. type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants