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] iOS not receiving push notifications sent from device but working when sent from firebase console #1797

Closed
callumclift opened this issue Jan 10, 2020 · 4 comments
Labels
impact: customer A bug with low impact (e.g. affecting only a few customers or has a workaround). (P3) plugin: messaging Stale Issue with no recent activity type: bug Something isn't working

Comments

@callumclift
Copy link

callumclift commented Jan 10, 2020

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)
@callumclift callumclift added the type: bug Something isn't working label Jan 10, 2020
@charkala
Copy link

I think I'm having a similar issue.
The payload received on Android is different from iOS.

My current work around is to check platform first then process the notification.
E.g. I include a type key in my payload:

var messageType = Platform.isIOS ? message['type'] : message['data']['type'];

@iapicca
Copy link

iapicca commented Jan 21, 2020

Hi @callumclift
did @charkala workaround fix the problem?
thank you

@iapicca iapicca added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Jan 21, 2020
@charkala
Copy link

@iapicca it didn't work and after some trial/error research and found to have the same issue outlined in #1829

@iapicca iapicca removed the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Feb 12, 2020
@Ehesp Ehesp added plugin: messaging impact: customer A bug with low impact (e.g. affecting only a few customers or has a workaround). (P3) labels Apr 22, 2020
@Salakar Salakar added the Stale Issue with no recent activity label Apr 1, 2021
@Salakar
Copy link
Member

Salakar commented Apr 16, 2021

Closing in favour of trying the latest messaging version which has since this issue was created been heavily reworked to improve it along with detailed documentation: https://firebase.flutter.dev/docs/messaging/overview

If you still have a problem please raise a new GitHub issue with up to date information and code snippets if possible. Thanks.

@Salakar Salakar closed this as completed Apr 16, 2021
@firebase firebase locked and limited conversation to collaborators May 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: customer A bug with low impact (e.g. affecting only a few customers or has a workaround). (P3) plugin: messaging Stale Issue with no recent activity type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants