Answered

Intercom causes crash on iOS if CarPlay is started

  • 15 March 2021
  • 4 replies
  • 181 views

If starting the app in CarPlay, Intercom causes the app to crash:

[CPTemplateApplicationScene windows]: unrecognized selector sent to instance

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CPTemplateApplicationScene windows]: unrecognized selector sent to instance 0x103386dc0'

terminating with uncaught exception of type NSException

Previously we haver setup Intercom in AppDelegate, but in preparation for CarPlay, we moved Intercom setup to SceneDelegate, as per the documentation.

Currently the only way to have Intercom be stable, is to uninstall the app and reinstall.

 

But that user experience is terrible.

icon

Best answer by Anonymous 15 March 2021, 17:45

View original

4 replies

Hey @emil a​. Thanks for reporting this. Can I just replay this to make sure I've understood correctly?

 

  • A user has your app installed, and that version of the app initialises the iOS SDK in the AppDelegate.
  • The user upgrades your app. The new version initialises the iOS SDK in the SceneDelegate and also adds support for CarPlay.
  • The app works fine on the iPhone but crashes whenever CarPlay is activated.
  • Uninstalling the app and then installing it again resolves the issue; the iOS SDK works as expected and there's no crash when CarPlay is activated.

 

Is that right? Is there anything I'm misunderstanding or missing there?

 

Along with confirming that understanding, it'd be good to understand which version of the iOS SDK you're using, which version of iOS you're seeing the issue with, and, if possible, it'd be good to get hold of the full stack trace. If you're using any wrappers (eg. for Cordova, React Native etc) it'd be good to know which of those you're using as well.

Hello 🙂

 

I have the same issue with the same error...

I added CarPlay on the app and I have initialised Intercom on AppDelegate.m inside "didFinishLaunchingWithOptions" method as 'react-native-intercom' package suggests..

If I comment out Intercom, CarPlay works fine, else the app crashes on CarPlay launch ..

 

In order to add CarPlay I have two Scenes on the App... One for CarPlay(CarPlaySceneDelegate.m) and one for iPhone(SceneDelegate.m)...

 

( It is interesting that if I open Intercom panel, by calling the 'displayMessageComposer' method, and after that connect to CarPlay, there is no crash. But If I disconnect and connect again to CarPlay with Intercom panel closed, app crashes in the same way. )

 

I am using React Native "0.63.3", iOS version 14, react-native-intercom "^19.0.0" ..

 

I already tried to Initialise Intercom on 'SceneDelegate.m' and to use the latest version on 'react-native-intercom' with no success ...

 

Here is the exact error:

```

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CPTemplateApplicationScene windows]: unrecognized selector sent to instance 0x7f94c2687160'

*** First throw call stack:

(

0  CoreFoundation           0x00007fff20421af6 __exceptionPreprocess + 242

1  libobjc.A.dylib           0x00007fff20177e78 objc_exception_throw + 48

2  CoreFoundation           0x00007fff204306f7 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0

3  UIKitCore              0x00007fff246cba43 -[UIResponder doesNotRecognizeSelector:] + 292

4  CoreFoundation           0x00007fff20426036 ___forwarding___ + 1489

5  CoreFoundation           0x00007fff20428068 _CF_forwarding_prep_0 + 120

6  Carge                0x00000001084ae93c -[ICMRootViewController findHostAppWindow] + 135

7  Carge                0x00000001084ae87c -[ICMRootViewController hostAppWindow] + 64

8  Carge                0x00000001084ab345 -[ICMRootViewController commonInit] + 34

9  Carge                0x00000001084ab2c2 -[ICMRootViewController initWithWindowScene:] + 98

10 Carge                0x000000010845c3cf -[ICMPresentationManager createIntercomWindowInScene:] + 91

11 Carge                0x000000010845c321 -[ICMPresentationManager sceneWillEnterForeground:] + 277

12 CoreFoundation           0x00007fff20362f12 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12

13 CoreFoundation           0x00007fff20362ee1 ___CFXRegistrationPost_block_invoke + 49

14 CoreFoundation           0x00007fff203625ff _CFXRegistrationPost + 454

15 CoreFoundation           0x00007fff20361f6d _CFXNotificationPost + 796

16 Foundation             0x00007fff207e598a -[NSNotificationCenter postNotificationName:object:userInfo:] + 59

17 UIKitCore              0x00007fff23cbafe1 -[_UISceneLifecycleMonitor willEnterForeground] + 270

18 UIKitCore              0x00007fff23cbbf0f __111-[_UIWindowSceneFBSSceneLifecycleMonitor transitionToTargetState:fromState:withTransitionContext:preparations:]_block_invoke_2.113 + 121

19 UIKitCore              0x00007fff24251d1e _UIScenePerformActionsWithLifecycleActionMask + 88

...

)

terminating with uncaught exception of type NSException CoreSimulator 732.18.6 - Device: iPhone 11 (7B6B0E39-7EB4-493E-8E0A-B0F9BDF57AFA) - Runtime: iOS 14.4 (18D46) - DeviceType: iPhone 11

```

Hi, I have the same error here, with the same stack trace. I use the last sdk available. Can you please suggest a way to resolve?

We are seeing the same issue mentioned here. 

The temporary workaround suggested in the below thread is working for us at the moment:

extension CPTemplateApplicationScene {
@objc var windows: UIWindow? { nil }
}

Linking here as I came across this thread first.

Reply