posthog-ios icon indicating copy to clipboard operation
posthog-ios copied to clipboard

Set `is_testflight` and `is_sideloaded` property

Open marandaneto opened this issue 1 year ago • 2 comments

Description

Relates to https://github.com/PostHog/posthog-android/issues/113 Sets a property if the running version was installed via testflight or its sideloaded.

  • [ ] iOS
  • [ ] Android
  • [ ] RN
  • [ ] Flutter will get it for free once Android and iOS are updated

marandaneto avatar Mar 14 '24 10:03 marandaneto

on iOS, you can check the appStoreReceiptURL https://developer.apple.com/documentation/foundation/bundle/1407276-appstorereceipturl https://stackoverflow.com/questions/26081543/how-to-tell-at-runtime-whether-an-ios-app-is-running-through-a-testflight-beta-i

Also https://github.com/ravitejaavv/store_checker/blob/master/ios/Classes/SwiftStoreCheckerPlugin.swift mobileprovision is another hint, if its not none of them, most likely is sideloaded.

marandaneto avatar Mar 14 '24 10:03 marandaneto

On Android, you can check packageManager.getInstallerPackageName(packageName), its null if its side loaded, or its the name of the installer (store). Its not possible to know at runtime if the Android app is installed for internal testing only since its the same binary. Here is the list of installer names https://github.com/ravitejaavv/store_checker/blob/feca50e3168763828e7aa024bb0b3c40b9ce42ab/lib/store_checker.dart#L31-L69

marandaneto avatar Mar 14 '24 10:03 marandaneto