microsoftconnect / ms-intune-app-sdk-ios

Intune App SDK for iOS enables data protection and mobile app management features in iOS mobile apps with Microsoft Intune
89 stars 25 forks source link

Linking of InTuneMAMSwift frameworks causes CarPlay initiated Siri requests to stall. #322

Closed StuSharpe closed 6 months ago

StuSharpe commented 1 year ago

Describe the bug: Linking of these Intune SDK frameworks:

causes Siri Intent Responses initiated via CarPlay (using the INStartCallIntent) to be stalled until the user brings the CarPlay scene into the foreground.

In particular, the UISceneDelegate.scene(_:continue:) method in the CarPlay UISceneDelegate does not get called immediately as expected. But rather this action is 'queued up' and will not trigger until either:

Simply unlinking the above frameworks resolves this issue, and Siri requests are relayed immediatey to the app via the UISceneDelegate.scene(_:continue:) method.

To Reproduce

Full Xcode demo project is available on request, but the setup is this:

  1. iOS project, that is set up for CarPlay with 'supports multiple scenes' enabled in the Info.plist, and seperate UISceneDelgate implementations for CarPlay (Info.plist attached)
  2. These InTune SDK frameworks included:
    • IntuneMAMSwift.xcframework
    • IntuneMAMSwiftStub.xcframework
  3. No other integration of InTune SDK features at runtime, (no import IntuneMAMSwift statements) just linking the libs is enough to reproduce the issue.
  4. Project has a single Siri Intents Extension, that implements the INStartCallIntent Intent
  5. The Siri Extension will pass the contact onto the app using the .continueInApp response code.

Reproduction Steps:

  1. Launch the app on the phone
  2. Connect phone to CarPlay
  3. Say a Siri Phrase using the CarPlay Siri function that activates the INStartCallIntent (e.g. "Call (NAME) using (APP)")
  4. Siri confirms the phrase "Call (NAME) using (APP)..."
  5. Wait for a while (minutes). Nothing happens (unexpected)
  6. Tap the app icon in CarPlay
  7. The Siri action will finally trigger at this point

Expected behavior:

  1. Launch the app on the phone
  2. Connect to CarPlay
  3. Say a Siri Phrase using the CarPlay Siri function that activates the INStartCallIntent (e.g. "Call using ")
  4. Siri confirms the phrase "Calling using ..."
  5. The Siri action triggers in app with no user interaction required

As noted above, simply unlinking the Intune SDK frameworks (removing completely from the project) is enough to restore the expected behavior

Screenshots and logs: Info.plist

Smartphone :

Also confirmed on iOS 15.5, and using real CarPlay hardware.

Intune App SDK for iOS :

Additional context:

As mentioned above, a demo project is available if it helps. (would require developer CarPlay entitlement on the Apple Developer account to run through CarPlay)

This seems specfic to Siri requests initiated via CarPlay. Siri requests initiated via the phone don't seem to exhibit this problem.

But any suggestions in the meantime are appreciated.

StuSharpe commented 1 year ago

Here's a video demonstrating the problem described above.

Any suggestions would be greatly appreciated.

darosal commented 1 year ago

Hi @StuSharpe, thanks for reaching out and thanks for the repro video of what's happening.

Just as a few sanity tests, does the behavior persist after following all the setup steps listed in the Build the SDK into your mobile app section of our docs?

Also, you had mentioned "Siri requests initiated via the phone don't seem to exhibit this problem", is this true when the request is initiated while the device is locked? I noticed on a local repro that the Siri intent will launch an app that uses CallKit if the device is unlocked (foregrounding it) but will not do so if the device is locked.

StuSharpe commented 1 year ago

Hi @darosal, thank you for responding.

I tried the running through the full sdk setup on the demo project, as you suggested. I found that if I went with the static library 'libIntuneMAMSwift.xcframework' ("Option 2 - Static Library", in the setup) instead of the recommended 'IntuneMamSwift.framework', the problem went away.

I'm unsure yet if this is a viable workaround in our case, I'll need to consult with our team.

I proceeded through most of the SDK setup steps with the regular framework setup too, to see if anything else made a difference, but nothing else seemed to affect it. See below.

I did some tests with the iPhone (unplugged from CarPlay) as you suggested. With the phone locked, the Siri command will prompt for the user to unlock their device before proceeding, but once unlocked (face ID or entering a code) the Siri intent works as expected, and the UIScene->continue method is hit without any additional user interaction.

Because you mentioned potential problems using CallKit, I also tried unlinking all the CallKit functionality (removing the CallKit framework also). But same behavior persists.

One additional detail I found:

I reset the project and went through all the SDK setup steps. I retested after each of the follow steps:

  1. Linking frameworks via dragging into XCode (Option 1 - Framework)
  2. Also tried Statically linking the 'libIntuneMAMSwift.xcframework' instead: (Option 2 - Static Library) <-- THIS SEEMED TO CHANGE THE BEHAVIOR HERE
  3. Add the IntuneMAMResources.bundle into the Copy Bundle Resources step in XCode
  4. Added all the additional frameworks
  5. Enabled keychain sharing
  6. Added the keychain sharing groups 'com.microsoft.intune.mam', 'com.microsoft.adalcache'
  7. Add the extra LSApplicationQueriesSchemes values in Info.plist
  8. Add the NSFaceIDUsageDescription entry in Info.plist
  9. Run the IntuneMAMConfigurator tool on our plist and entitlements files.
  10. XCode Settings: Set "Enable BitCode" and "Strip Swift Symbols" to NO
  11. Add IntuneMAMSettings into the plist (copied from our main app)

I stopped around here, I didn't proceed further with the File Provider extension or MSAL setup - but if you think this is useful to try I can proceed through the full setup.

StuSharpe commented 1 year ago

Hi @darosal

So, it seems the static lib workaround (above) has turned out to be a red-herring. Once I got the static lib linking correctly, the problem reappeared.

So I think we're back to square one here. Having working Siri integration is a requirement to ship a CarPlay-enabled app on the app store, so this is a big blocker for us right now. So more than happy to try out any suggestions you may have.

Stu.

ShruthiAchutha commented 6 months ago

Closing stale issues. Please reopen if you still need help with this.