Description
Description
We've noticed a significant surge in iOS user sessions within Google Analytics 4, primarily originating from Firebase (the Firebase SDK integrated into our iOS app). However, the recorded session counts seem disproportionate compared to other metrics we track. This inconsistency has led us to suspect that our session counts might be inflated.
One hypothesis I've been exploring relates to the behaviour of our app when it enters the background and iOS terminates it, Subsequently upon receiving a silent push notification iOS relaunches the app in the background, triggering the standard lifecycle functions of the AppDelegate, including application(_:didFinishLaunchingWithOptions:).
Despite thorough investigation, I've yet to find a resolution to this issue. While researching, I've encountered similar issues raised by others (now closed), although not specifically related to silent push notifications. One such discussion can be found here: #6161. I'm curious if the iOS Firebase SDK has any logic to determine whether the app was launched via silent push and prevent any session_start
events being fired.
Your insights or suggestions on addressing this matter would be greatly appreciated. Thank you.
Reproducing the issue
Because of the nature of the issue I have found it really difficult to reproduce the issue. I have been able to reproduce the app being launched in the background via silent push by following these steps:
Using a physical device that already has the app you want to test installed on (and registered for push)
- Select Your Scheme: At the top left corner of the Xcode window, you'll see a toolbar with your project name and a "scheme" dropdown menu next to it. Click on the scheme dropdown menu and select "Edit Scheme..." from the dropdown list.
- Choose Run Configuration: In the Scheme editor window that appears, make sure "Run" is selected on the left sidebar.
- Edit Run Options: In the main area of the Scheme editor window, select the "Info" tab.
- Change Launch Behavior: Under the "Launch" section, you'll see a dropdown menu labeled "Launch". By default, it's set to "Automatically". Change this to "Wait for executable to be launched".
- Close Scheme Editor: Click the "Close" button to save your changes and close the Scheme editor window.
- Run Your App: Now when you run your app from Xcode (by clicking the play button or using the shortcut Command + R), Xcode will wait for the app to be launched before attaching the debugger.
- Send Silent Push: Send a silent push to the device that the app is being ran on. If this has successfully been received in Xcode you should see the app's status switch to running rather than waiting to launch/execute.
I have found it difficult to get the Firebase DebugView to work properly with this method (it is very inconsistent). Along with this I have to wait for the session to end before I can test again so its a timely process to try and debug the issue.
Firebase SDK Version
10.2.0
Xcode Version
15.1
Installation Method
Swift Package Manager
Firebase Product(s)
Analytics
Targeted Platforms
iOS
Relevant Log Output
No response
If using Swift Package Manager, the project's Package.resolved
Expand Package.resolved
snippet
Replace this line with the contents of your Package.resolved.
If using CocoaPods, the project's Podfile.lock
Expand Podfile.lock
snippet
Replace this line with the contents of your Podfile.lock!