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] Add support for handling messages in background for iOS #53

Closed
wants to merge 5 commits into from

Conversation

genert
Copy link

@genert genert commented Aug 28, 2019

Description

When Flutter app is in the background or terminated allow it to handle incoming FCM messages. When the application starts an additional background channel is started to handle incoming messages when the app is not in the foreground.

Related Issues

See #47

Remaining work

TODOs before this can be merged

@genert
Copy link
Author

genert commented Aug 28, 2019

This was largely based on @athornz solution. Please give it a look.

@genert
Copy link
Author

genert commented Sep 11, 2019

Update: I will work on this tomorrow.

@Niek
Copy link

Niek commented Oct 1, 2019

Any chance that this can be merged soon?

@Niek
Copy link

Niek commented Oct 1, 2019

BTW, I'm getting this exception when trying to run the sample:

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM objectAtIndexedSubscript:]: unrecognized selector sent to instance 0x60000296cd20'
terminating with uncaught exception of type NSException
abort() called
CoreSimulator 681.5.1 - Device: iPhone 11 Pro Max (850D6B32-240C-42D5-961F-CB2F0A2D9C70) - Runtime: iOS 13.0 (17A577a) - DeviceType: iPhone 11 Pro Max

Application Specific Backtrace 1:
0   CoreFoundation                      0x00007fff23b98bde __exceptionPreprocess + 350
1   libobjc.A.dylib                     0x00007fff503b5b20 objc_exception_throw + 48
2   CoreFoundation                      0x00007fff23bb9704 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3   CoreFoundation                      0x00007fff23b9d7bc ___forwarding___ + 1436
4   CoreFoundation                      0x00007fff23b9f6c8 _CF_forwarding_prep_0 + 120
5   Runner                              0x0000000105c38eea -[FLTFirebaseMessagingPlugin handleMethodCall:result:] + 858
6   Flutter                             0x0000000107a8f4fd __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 104
7   Flutter                             0x0000000107a28ec0 _ZNK7flutter21PlatformMessageRouter21HandlePlatformMessageEN3fml6RefPtrINS_15PlatformMessageEEE + 166
8   Flutter                             0x0000000107a2c780 _ZN7flutter15PlatformViewIOS21HandlePlatformMessageEN3fml6RefPtrINS_15PlatformMessageEEE + 38
9   Flutter                             0x0000000107a89db3 _ZNSt3__110__function6__funcIZN7flutter5Shell29OnEngineHandlePlatformMessageEN3fml6RefPtrINS2_15PlatformMessageEEEE4$_31NS_9allocatorIS8_EEFvvEEclEv + 57
10  Flutter                             0x0000000107a3b3f1 _ZN3fml15MessageLoopImpl10FlushTasksENS_9FlushTypeE + 123
11  Flutter                             0x0000000107a40742 _ZN3fml17MessageLoopDarwin11OnTimerFireEP16__CFRunLoopTimerPS0_ + 26
12  CoreFoundation                      0x00007fff23afc1e4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
13  CoreFoundation                      0x00007fff23afbed2 __CFRunLoopDoTimer + 1026
14  CoreFoundation                      0x00007fff23afb52a __CFRunLoopDoTimers + 266
15  CoreFoundation                      0x00007fff23af629e __CFRunLoopRun + 2238
16  CoreFoundation                      0x00007fff23af56b6 CFRunLoopRunSpecific + 438
17  GraphicsServices                    0x00007fff3815cbb0 GSEventRunModal + 65
18  UIKitCore                           0x00007fff47162a67 UIApplicationMain + 1621
19  Runner                              0x0000000105b36db0 main + 112
20  libdyld.dylib                       0x00007fff5123bcf5 start + 1

(my myBackgroundMessageHandler is static, so that shouldn't be causing it)

@genert
Copy link
Author

genert commented Oct 3, 2019

We ended up rolling native part for handling Firebase messaging due business logic requirements. Thus I have not worked on this.

Perhaps, someone can take over or create a new one.

```
<application android:name=".Application" ...>
```
1. For iOS (Swift)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where to add this code in ios? like android we create an Application class

@josh-burton
Copy link
Contributor

So is this PR dead?

@genert
Copy link
Author

genert commented Jan 15, 2020

@athornz Yes, we went with native solution instead (APNs with notification service extension).

Will close this now, feel free to work on this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants