ios icon indicating copy to clipboard operation
ios copied to clipboard

iOS App running on iOS 14 crashes every-time new push comes #1569

Open saurabh874 opened this issue 4 years ago • 31 comments

Device iPhone X version- iOS 14 beta version.

App is crashing every time once new push come. anyone have solution for this.

saurabh874 avatar Jul 30 '20 06:07 saurabh874

Getting same issue, Can someone please check this , app is crashing on push only in iOS 14 getting this execption -

EXC_BREAKPOINTRNCPushNotificationIOS.m:273
drogonIOS/node_modules/@react-native-community/push-notification-ios/ios/RNCPushNotificationIOS.m:273:3 -[RNCPushNotificationIOS onFinishRemoteNotification:fetchResult:]

San10694 avatar Aug 25 '20 06:08 San10694

iOS 14 is released today, and we're experiencing this in our production app right now. I'll try to do some investigating myself and report back here, but I am generally unfamiliar with the implementation of push-notification-ios. Would appreciate any insight the rest of the community can provide on this crash.

sunweiyang avatar Sep 16 '20 21:09 sunweiyang

The crash happens consistently when a push notification comes in on an iOS 14 device, in this code block (line 287 of RNCPushNotificationIOS.m):

Screen Shot 2020-09-16 at 10 43 34 PM

It seems that the crash is related to this addition to AppDelegate.m required by the push-notification-ios's README:

// Required for the notification event. You must call the completion handler after handling the remote notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

When I comment out [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];, no crash occurs with iOS 14. But there may be unintended side effects? Maintainers and knowledgeable folks, please advise.

Here is the Xcode debug console output at the time of the crash:

2020-09-16 22:40:16.390423-0500 Skale[1427:180516] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}>
2020-09-16 22:40:16.390553-0500 Skale[1427:180516] [ProcessSuspension] 0x1175611c0 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 1431, error: Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}
2020-09-16 22:40:16.397587-0500 Skale[1427:180516] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}>
2020-09-16 22:40:16.397667-0500 Skale[1427:180516] [ProcessSuspension] 0x117561240 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 1431, error: Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}
2020-09-16 22:40:23.704512-0500 Skale[1427:180688] [connection] nw_read_request_report [C8] Receive failed with error "Software caused connection abort"
2020-09-16 22:40:23.710848-0500 Skale[1427:180688] [connection] nw_read_request_report [C23] Receive failed with error "Software caused connection abort"
2020-09-16 22:40:23.711262-0500 Skale[1427:180688] [connection] nw_read_request_report [C15] Receive failed with error "Software caused connection abort"
2020-09-16 22:40:23.711968-0500 Skale[1427:180688] [connection] nw_read_request_report [C14] Receive failed with error "Software caused connection abort"
2020-09-16 22:40:23.715756-0500 Skale[1427:180688] [connection] nw_read_request_report [C21] Receive failed with error "Software caused connection abort"
2020-09-16 22:40:23.716220-0500 Skale[1427:180688] [connection] nw_read_request_report [C17] Receive failed with error "Software caused connection abort"
2020-09-16 22:40:23.750165-0500 Skale[1427:180688] Connection 1: received failure notification
2020-09-16 22:40:23.750264-0500 Skale[1427:180688] [connection] nw_flow_add_write_request [C1 192.168.1.113:8081 failed channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] cannot accept write requests
2020-09-16 22:40:23.750310-0500 Skale[1427:180688] [connection] nw_write_request_report [C1] Send failed with error "Socket is not connected"
2020-09-16 22:40:23.773660-0500 Skale[1427:180688] Connection 16: received failure notification
2020-09-16 22:40:23.773720-0500 Skale[1427:180688] [connection] nw_flow_add_write_request [C16.1 52.205.86.27:443 failed channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] cannot accept write requests
2020-09-16 22:40:23.773755-0500 Skale[1427:180688] [connection] nw_write_request_report [C16] Send failed with error "Socket is not connected"
2020-09-16 22:40:23.774000-0500 Skale[1427:180688] Connection 18: received failure notification
2020-09-16 22:40:23.774857-0500 Skale[1427:180688] [connection] nw_flow_add_write_request [C18.1 52.205.86.27:443 failed channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] cannot accept write requests
2020-09-16 22:40:23.775031-0500 Skale[1427:180688] [connection] nw_write_request_report [C18] Send failed with error "Socket is not connected"
2020-09-16 22:40:23.775966-0500 Skale[1427:180688] Connection 19: received failure notification
2020-09-16 22:40:23.776011-0500 Skale[1427:180688] [connection] nw_flow_add_write_request [C19.1 52.205.86.27:443 failed channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] cannot accept write requests
2020-09-16 22:40:23.776042-0500 Skale[1427:180688] [connection] nw_write_request_report [C19] Send failed with error "Socket is not connected"
2020-09-16 22:40:23.777389-0500 Skale[1427:180688] Connection 20: received failure notification
2020-09-16 22:40:23.778188-0500 Skale[1427:180688] [connection] nw_flow_add_write_request [C20.1 52.205.86.27:443 failed channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] cannot accept write requests
2020-09-16 22:40:23.778458-0500 Skale[1427:180688] [connection] nw_write_request_report [C20] Send failed with error "Socket is not connected"
2020-09-16 22:40:23.778798-0500 Skale[1427:180688] Connection 24: received failure notification
2020-09-16 22:40:23.778835-0500 Skale[1427:180688] [connection] nw_flow_add_write_request [C24.2 20.185.73.23:443 failed channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] cannot accept write requests
2020-09-16 22:40:23.778864-0500 Skale[1427:180688] [connection] nw_write_request_report [C24] Send failed with error "Socket is not connected"
2020-09-16 22:40:23.781361-0500 Skale[1427:180688] Connection 27: received failure notification
2020-09-16 22:40:23.783075-0500 Skale[1427:180688] [connection] nw_flow_add_write_request [C27.1 20.185.73.23:443 failed channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] cannot accept write requests
2020-09-16 22:40:23.783238-0500 Skale[1427:180688] [connection] nw_write_request_report [C27] Send failed with error "Socket is not connected"
2020-09-16 22:40:23.783869-0500 Skale[1427:180688] Connection 13: received failure notification
2020-09-16 22:40:23.783911-0500 Skale[1427:180688] [connection] nw_flow_add_write_request [C13 192.168.1.113:8081 failed channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] cannot accept write requests
2020-09-16 22:40:23.783943-0500 Skale[1427:180688] [connection] nw_write_request_report [C13] Send failed with error "Socket is not connected"
2020-09-16 22:40:23.798754-0500 Skale[1427:180688] Connection 11: received failure notification
2020-09-16 22:40:23.798826-0500 Skale[1427:180688] [connection] nw_flow_add_write_request [C11 192.168.1.113:8081 failed channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] cannot accept write requests
2020-09-16 22:40:23.798865-0500 Skale[1427:180688] [connection] nw_write_request_report [C11] Send failed with error "Socket is not connected"
2020-09-16 22:40:23.801061-0500 Skale[1427:180688] Connection 22: received failure notification
2020-09-16 22:40:23.801110-0500 Skale[1427:180688] [connection] nw_flow_add_write_request [C22 192.168.1.113:8081 failed channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] cannot accept write requests
2020-09-16 22:40:23.801142-0500 Skale[1427:180688] [connection] nw_write_request_report [C22] Send failed with error "Socket is not connected"

sunweiyang avatar Sep 17 '20 04:09 sunweiyang

@saurabh874 @San10694 the workaround I'm currently deciding on is to comment out line 287 of RNCPushNotificationIOS.m (completionHandler(result);). This allows the app to receive push notifications while avoiding crashes and keep the ability to trigger local notifications. There may still be some side effects that I'm not aware of; perhaps a maintainer can provide some insight?

sunweiyang avatar Sep 17 '20 04:09 sunweiyang

Same issue

ysfzrn avatar Sep 23 '20 12:09 ysfzrn

same issue, any update?

surafelbm avatar Sep 23 '20 18:09 surafelbm

did anyone manage to solve it?

alex-mironov avatar Oct 13 '20 19:10 alex-mironov

https://github.com/react-native-community/push-notification-ios/issues/163#issuecomment-693818811 This workaround works for me but I suppose no new update

ysfzrn avatar Oct 13 '20 21:10 ysfzrn

@saurabh874 @San10694 the workaround I'm currently deciding on is to comment out line 287 of RNCPushNotificationIOS.m (completionHandler(result);). This allows the app to receive push notifications while avoiding crashes and keep the ability to trigger local notifications. There may still be some side effects that I'm not aware of; perhaps a maintainer can provide some insight?

Work around also worked for me.

blexxed avatar Oct 14 '20 11:10 blexxed

I am facing the same issue on react native 0.63.3, ios 14.0.1.

ghasemikasra39 avatar Oct 19 '20 09:10 ghasemikasra39

I am noticing this too on my app since ios 14

bneigher avatar Oct 25 '20 20:10 bneigher

Hello! I'm trying to address this issue with my iOS14 device, but I'm unable to reproduce the issue. onFinishRemoteNotification mentioned in comment https://github.com/react-native-push-notification-ios/push-notification-ios/issues/163#issuecomment-693797255 seems to be called fine on my side.

Would someone be able to create a reproduction repo for this issue?

Naturalclar avatar Oct 26 '20 05:10 Naturalclar

@Naturalclar Yes Still we are facing same issue. and this issue is come only when app is in foreground. Screenshot 2020-10-26 at 11 19 46 AM

saurabh874 avatar Oct 26 '20 05:10 saurabh874

Hello! I'm trying to address this issue with my iOS14 device, but I'm unable to reproduce the issue. onFinishRemoteNotification mentioned in comment #163 (comment) seems to be called fine on my side.

Would someone be able to create a reproduction repo for this issue?

You only need device on ios 14 and app in foreground receiving push

tmmgn avatar Oct 26 '20 07:10 tmmgn

I'm using a physical iOS 14.1 device (iPhone 7) tried both local notification and push notification (using Pusher), tried both foreground and background but the notification seems to work fine. I'm using the example app in this repo.

Naturalclar avatar Oct 26 '20 07:10 Naturalclar

It will help if some one can provide a repository that will reproduce the crash so I could investigate further :)

Naturalclar avatar Oct 26 '20 07:10 Naturalclar

Hi @Naturalclar it will very helpful if you to comment out line 287 of RNCPushNotificationIOS.m (completionHandler(result);) because i comment out this line and it is perfectly working.

saurabh874 avatar Oct 28 '20 06:10 saurabh874

tried on fresh RN 0.63.3 with GCM push notification - crash on every device with iOS 14+, maybe push provider is the reason

tmmgn avatar Oct 28 '20 11:10 tmmgn

btw on simulator push notifications works perfect even in foreground, got crash only in test flight and production

tmmgn avatar Oct 30 '20 14:10 tmmgn

Any updates? I'm also getting this on RN 0.59.9, iOS 14+, iPhone12,3

HilaRaveh avatar Nov 02 '20 12:11 HilaRaveh

I have same issue, commenting completionHandler(result) is not safe solution.

DovletAmanov avatar Nov 04 '20 22:11 DovletAmanov

Also having the same issue on RN 0.61.4, iOS 14+. Was able to resolve by commenting the line recommended above, but following to see if the issue is resolved.

haileybee1231 avatar Nov 10 '20 16:11 haileybee1231

I've released 1.7.5-beta.0 with potential fix for this. I wasn't able to reproduce the crash with the original package, so could someone verify that this change fixes the crash?

Naturalclar avatar Nov 22 '20 07:11 Naturalclar

Sorry, 1.7.5-beta.0 didn't fix my problem. After commenting out completionHandler(result) like before, crash didn't occur

Screen Shot 2020-11-24 at 14 40 48

ysfzrn avatar Nov 24 '20 11:11 ysfzrn

released v1.8.0 that should fix the issue

Naturalclar avatar Nov 25 '20 18:11 Naturalclar

Thanks @Naturalclar! Can you share what was the issue, and why moving completionHandler() resolves it?

sunweiyang avatar Nov 25 '20 22:11 sunweiyang

can confirm, version 1.8.0 not crashing anymore, but foreground push is not visible (event is firing)

tmmgn avatar Nov 27 '20 08:11 tmmgn

@tmmgn I'm using PushNotificationIOS.presentLocalNotification for iOS instead of PushNotification.localNotification , maybe it can resolve your problem. I realized now, presentLocalNotification seems deprecated. I suppose, suggested new function is addNotificationRequest

ysfzrn avatar Nov 27 '20 08:11 ysfzrn

I was facing the same problem in one of my projects, it seems that Apple has changed some very important aspects of Push notifications which affected many apps out there. It was possible to fix this issue following the steps posted by the user "edelabar_pmd" on their official forum: https://developer.apple.com/forums/thread/660149

Although after following the changes in the link above I found out that all these errors were gone for users running the app on iOS 14.2. I imagine it could be a very strong lead to first try building the app in this version before trying to change anything in the code (as this probably seems to be Apple's mistake, not the library's).

gabcvit avatar Nov 27 '20 08:11 gabcvit

if you use RN 0.63.2 and fire-base ver 5.6.x Please follow the following link. It worked for me !!!! ios 14 tap push crash

thuynt99 avatar Mar 01 '21 07:03 thuynt99