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] Redirect not working on iOS #3868

Closed
Thorbenl opened this issue Oct 15, 2020 · 7 comments · Fixed by #4012
Closed

🐛 [firebase_messaging] Redirect not working on iOS #3868

Thorbenl opened this issue Oct 15, 2020 · 7 comments · Fixed by #4012
Assignees
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. type: bug Something isn't working

Comments

@Thorbenl
Copy link

I would like to redirect to a specific screen on tapping the push notification..

      _firebaseMessaging.configure(
          onMessage: (Map<String, dynamic> message) async {
            print("onMessage: $message");
        if (message['data'].containsKey('thread_id')) {
          _navigateToInbox(message);
        }
      }, onLaunch: (Map<String, dynamic> message) async {
        print("onLaunch: $message");
        if (message['data'].containsKey('thread_id')) {
          _navigateToInbox(message);
        }
      }, onResume: (Map<String, dynamic> message) async {
        print("onResume: $message");
        if (message['data'].containsKey('thread_id')) {
          _navigateToInbox(message);
        }
      });

The _navigateToInbox looks like this:

  Future<Object> _navigateToInbox(Map<String, dynamic> message) {
    final threadId = int.parse(message['data']['thread_id']);
    return MyApp.navigatorKey.currentState
        .pushNamed(ThreadScreen.routeName, arguments: threadId);
  }

So i am using the global navigatorKey. This works super fine for Android, iOS just opens the app and does nothing :( Not sure if i am missing anything?

Here is the payload from onResume:

{notification: {}, data: {collapse_key: key, thread_id: 35626, google.original_priority: normal, google.sent_time: 1602751694832, google.delivered_priority: normal, google.ttl: 2419200, from: 894395737756, click_action: FLUTTER_NOTIFICATION_CLICK, google.message_id: 0:1602751694837303%3d33f9053d33f905}}

Here is the output of flutter doctor -v

[✓] Flutter (Channel stable, 1.22.1, on Mac OS X 10.15.7 19H2, locale en-DK)
    • Flutter version 1.22.1 at /Users/turbz/flutter
    • Framework revision f30b7f4db9 (7 days ago), 2020-10-08 10:06:30 -0700
    • Engine revision 75bef9f6c8
    • Dart version 2.10.1

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/turbz/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = /Users/turbz/Library/Android/sdk
    • Java binary at: /Users/turbz/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6821437/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 /Users/turbz/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6821437/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.50.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.15.0


[✓] Connected device (2 available)
    • ONEPLUS A6003 (mobile)      • 1b1258f                   • android-arm64 • Android 10 (API 29)
    • iPhone von Jacob (mobile) • 00008030-001125360AE1802E • ios           • iOS 13.7

• No issues found!

Is this a bug? Or intended? Do I miss something?

@Thorbenl Thorbenl added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Oct 15, 2020
@Thorbenl Thorbenl changed the title 🐛 [PLUGIN_NAME_HERE] Your issue title here 🐛 [firebase_messaging] Redirect not working on iOS Oct 15, 2020
@dackers86
Copy link
Member

Hi @Thorbenl

Does the navigation issue work outside of messaging.

For example if you created a button to see if navigation still works as expected?

@dackers86 dackers86 self-assigned this Oct 15, 2020
@TahaTesser TahaTesser added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Oct 20, 2020
@RenanDelfanti
Copy link

RenanDelfanti commented Oct 21, 2020

Same problem here only on ios.
Any news?

@dackers86
Copy link
Member

@RenanDelfanti Could you provide a minimal example?

We need to confirm that navigation is working as expected as i'm not sure why this would be related to messaging

@RenanDelfanti
Copy link

@dackers86 Yes, navigation works normally in the entire app.
The @Thorbenl example is very similar to mine.
And on android it works normally.

@RenanDelfanti
Copy link

RenanDelfanti commented Oct 22, 2020

The only difference between my code and his is that I test a parameter I receive from FCM on my navigation function.
EX:

Future<void> _navigateToBlog(Map<String, dynamic> message) {
  try {
    final extra = int.parse(message['data']['extra']);
    Get.to(BlogPage(extra: extra));
  } catch (err) {
    print(err);
  }
}

@RenanDelfanti
Copy link

RenanDelfanti commented Oct 22, 2020

On Android we need to add on manifest to work:

<intent-filter>
    <action android:name="FLUTTER_NOTIFICATION_CLICK" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

On iOS do we need to do something similar to work?

@RenanDelfanti
Copy link

I found that the message object on android is different from iOS

I solved my problem with this code:

extra = Platform.isAndroid ? message['data']['extra'] : message['extra'];

@firebase firebase locked and limited conversation to collaborators Dec 4, 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. type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants