Skip to content

[Firebase Messaging] iOS not receiving push notifications sent from device but working when sent from firebase console #1797

Closed
@callumclift

Description

@callumclift

Describe the bug

I'm not receiving any push notifications at all on iOS devices when sending messages from within my app to individually targeted devices. Nothing comes through in the tray at all and the onMessage handler is not getting fired at all no matter if the app is open, in the background or closed. I'm just not receiving anything at all, i'm using both a real iPhone X and an iPad.

When I send a message to all users through the firebase console the push notification is received on iOS devices and the onMessage handler is working so devices are clearly set up to receive push notifications correctly.

Messages are received totally fine on Android when sending from within the app so I don't think it's an issue in the way i'm sending the messages.

I'm using the latest version of the firebase messaging plugin (firebase_messaging: ^6.0.9)

Is this a know issue? Is anyone else experiencing this? Really frustrating as push notifications are vital to users of my app

This is my code for sending the notification:

await http.post(
          'https://fcm.googleapis.com/fcm/send',
          headers: <String, String>{
            'Content-Type': 'application/json',
            'Authorization': 'key=$cloudMessagingServerKey',
          },
          body: jsonEncode(
            <String, dynamic>{
              'notification': <String, dynamic>{
                'body': body,
                'title': title
              },
              'priority': 'high',
              'data': <String, dynamic>{
                'click_action': 'FLUTTER_NOTIFICATION_CLICK',
              },
              'to': token,
            },
          ),
        );
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-GB)
    • Flutter version 1.12.13+hotfix.5 at /Users/callumclift/appDevelopment/flutter
    • Framework revision 27321ebbad (4 weeks ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/callumclift/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 28.0.3
    • ANDROID_HOME = /Users/callumclift/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

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

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 41.1.2
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Community Edition (version 2017.3.5)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 25.0.1
    • Dart plugin version 173.4700

[✓] Connected device (2 available)
    • Android SDK built for x86 • emulator-5554                        • android-x86 • Android 8.1.0 (API 27) (emulator)
    • iPhone 11                 • 19513789-DB20-42A1-B7F9-B5B2C43BC80F • ios         • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)

• No issues found!

flutter run --verbose

[  +27 ms] executing: [/Users/callumclift/appDevelopment/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +40 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] 27321ebbad34b0a3fafe99fac037102196d655ff
[        ] executing: [/Users/callumclift/appDevelopment/flutter/] git describe --match v*.*.* --first-parent --long --tags
[  +41 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v1.12.13+hotfix.5-0-g27321ebba
[   +7 ms] executing: [/Users/callumclift/appDevelopment/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +10 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [/Users/callumclift/appDevelopment/flutter/] git ls-remote --get-url origin
[   +9 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +51 ms] executing: [/Users/callumclift/appDevelopment/flutter/] git rev-parse --abbrev-ref HEAD
[  +11 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[   +5 ms] executing: sw_vers -productName
[  +16 ms] Exit code 0 from: sw_vers -productName
[        ] Mac OS X
[        ] executing: sw_vers -productVersion
[  +13 ms] Exit code 0 from: sw_vers -productVersion
[        ] 10.15.2
[        ] executing: sw_vers -buildVersion
[  +15 ms] Exit code 0 from: sw_vers -buildVersion
[        ] 19C57
[  +32 ms] executing: /usr/bin/xcode-select --print-path
[  +10 ms] Exit code 0 from: /usr/bin/xcode-select --print-path
[        ] /Applications/Xcode.app/Contents/Developer
[   +1 ms] executing: /usr/bin/xcodebuild -version
[ +670 ms] Exit code 0 from: /usr/bin/xcodebuild -version
[   +3 ms] Xcode 11.3
           Build version 11C29
[  +74 ms] executing: /Users/callumclift/Library/Android/sdk/platform-tools/adb devices -l
[   +7 ms] Exit code 0 from: /Users/callumclift/Library/Android/sdk/platform-tools/adb devices -l
[        ] List of devices attached
           emulator-5554          device product:sdk_gphone_x86 model:Android_SDK_built_for_x86 device:generic_x86 transport_id:2
[  +18 ms] executing: /Users/callumclift/appDevelopment/flutter/bin/cache/artifacts/libimobiledevice/idevice_id -h
[  +51 ms] /usr/bin/xcrun simctl list --json devices
[ +135 ms] More than one device connected; please specify a device with the '-d <deviceId>' flag, or use '-d all' to act on all devices.
[   +3 ms] /Users/callumclift/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell getprop
[  +25 ms] ro.hardware = ranchu
[   +4 ms] Android SDK built for x86 • emulator-5554                        • android-x86 • Android 8.1.0 (API 27) (emulator)
[        ] iPhone 11                 • 19513789-DB20-42A1-B7F9-B5B2C43BC80F • ios         • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
[  +10 ms] "flutter run" took 1,113ms.

#0      throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
#1      RunCommand.validateCommand (package:flutter_tools/src/commands/run.dart:289:7)
<asynchronous suspension>
#2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:590:11)
#3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:515:33)
<asynchronous suspension>
#4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:146:29)
#5      _rootRun (dart:async/zone.dart:1126:13)
#6      _CustomZone.run (dart:async/zone.dart:1023:19)
#7      _runZoned (dart:async/zone.dart:1518:10)
#8      runZoned (dart:async/zone.dart:1465:12)
#9      AppContext.run (package:flutter_tools/src/base/context.dart:145:18)
#10     FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:505:20)
#11     CommandRunner.runCommand (package:args/command_runner.dart:197:27)
#12     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:413:21)
<asynchronous suspension>
#13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:146:29)
#14     _rootRun (dart:async/zone.dart:1126:13)
#15     _CustomZone.run (dart:async/zone.dart:1023:19)
#16     _runZoned (dart:async/zone.dart:1518:10)
#17     runZoned (dart:async/zone.dart:1465:12)
#18     AppContext.run (package:flutter_tools/src/base/context.dart:145:18)
#19     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:364:19)
#20     CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:112:25)
#21     new Future.sync (dart:async/future.dart:224:31)
#22     CommandRunner.run (package:args/command_runner.dart:112:14)
#23     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:250:18)
#24     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:63:22)
#25     _rootRun (dart:async/zone.dart:1126:13)
#26     _CustomZone.run (dart:async/zone.dart:1023:19)
#27     _runZoned (dart:async/zone.dart:1518:10)
#28     runZoned (dart:async/zone.dart:1502:12)
#29     run.<anonymous closure> (package:flutter_tools/runner.dart:61:18)
<asynchronous suspension>
#30     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:146:29)
#31     _rootRun (dart:async/zone.dart:1126:13)
#32     _CustomZone.run (dart:async/zone.dart:1023:19)
#33     _runZoned (dart:async/zone.dart:1518:10)
#34     runZoned (dart:async/zone.dart:1465:12)
#35     AppContext.run (package:flutter_tools/src/base/context.dart:145:18)
#36     runInContext (package:flutter_tools/src/context_runner.dart:64:24)
#37     run (package:flutter_tools/runner.dart:50:10)
#38     main (package:flutter_tools/executable.dart:65:9)
#39     main (file:///Users/callumclift/appDevelopment/flutter/packages/flutter_tools/bin/flutter_tools.dart:8:3)
#40     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:32)
#41     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)

Metadata

Metadata

Assignees

No one assigned

    Labels

    StaleIssue with no recent activityimpact: customerA bug with low impact (e.g. affecting only a few customers or has a workaround). (P3)plugin: messagingtype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions