Monday, April 11, 2022

Using WebRTC in your iOS app (what the official documentation will not tell you)

The documentation is prety extensive and when followed you can successfully get it running in both your simulator and device. However, you are in for two surprises!!!

1st Surprise

Documentation doesn't tell you about their branching strategy. If you are like me and would always keep your 'master' branch stable and in a releasable state, you are in for surprise with WebRTC repository. I will start off saying, "please don't assume the 'master' is stable". Therefore it is not wise to checkout their latest master and build the framework and use it in your app. This is what you would be doing if you just follow the instructions in the documentation. Instead what you must do is look for the 'stable' tag in their commit history. They have three main tags.

  • stable
  • beta
  • dev

Commit history can be found here https://chromiumdash.appspot.com/commits?repo=webrtc&platform=iOS

Release history can be found here https://chromiumdash.appspot.com/releases?platform=iOS

2nd Surprise

Apple has been rejecting WebRTC frameworks since April 2020. WebRTC is allegedly using private APIs. If you submit an app with a bitcode enabled WebRTC framework created following the official documentation you will get a rejection mail from Apple like the one below.

ITMS-90338: Non-public API usage - The app references non-public selectors in "My App Name": determineAppInstallationAttributionWithCompletionHandler:, didTap, initWithURLStrings:, lookupAdConversionDetails:, sdp. If method names in your source code match the private Apple APIs listed above, altering your method names will help prevent this app from being flagged in future submissions. In addition, note that one or more of the above APIs may be located in a static library that was included with your app. If so, they must be removed. For further information, visit the Technical Support Information at http://developer.apple.com/support/technical/

The issue was first reported here https://bugs.chromium.org/p/webrtc/issues/detail?id=11492&q=references%20non-public%20selectors&can=2

Brought in to attention for the second time again here https://bugs.chromium.org/p/webrtc/issues/detail?id=13925&q=references%20non-public%20selectors&can=2

Developers at Google are still not convinced that this is an issue worth their valuable time. Luckily some nice developers decided to share their fix with the rest of us. The fix is not official but I have personally tested the framework both in simulator and device. WebRTC framework is used for live audio streaming in the app I maintain. We selected WebRTC because we wanted something that works on all three platforms iOS, Android and Web. I can also confirm that it passes Apple appstore review.

Below is the link to the WebRTC repo that works in all architectures and also accepted by Apple.

https://github.com/jitsi/webrtc

Hope Google will prompt you this blog post when your WebRTC app gets rejected by Apple.

No comments: