-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
...ornsAnalytics.xcworkspace/xcuserdata/barbayrak.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Papcorns Analytics iOS SDK -> Swift 5 | ||
|
||
Add the following line to your Podfile | ||
|
||
``` | ||
pod 'PapcornsAnalytics' | ||
``` | ||
|
||
# Integrate the SDK into your app | ||
|
||
|
||
``` | ||
import PapcornsAnalytics | ||
``` | ||
|
||
Initialize PapcornsAnalytics in the `didFinishLaunching` or `didFinishLaunchingWithOptions` method of your AppDelegate file | ||
|
||
``` | ||
var appVersion = "" | ||
if let versionString = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String { | ||
appVersion = versionString | ||
} | ||
PapcornsAnalytics.configure(appId: "INSERT YOUR APP ID HERE", appVersion: appVersion) | ||
``` | ||
|
||
Replace "INSERT YOUR APP ID HERE" string with id given to you | ||
|
||
# Setting User Id | ||
|
||
Before calling logEvent or logScreen you need to set `PapcornsAnalytics.logEvent` with parameters [String:Any] whenever you need to trigger an event like in app purchases or signups etc.. , if there is no parameter then leave it with blank dictionary which is [:] .In event naming convension start with lowercased letter | ||
|
||
``` | ||
PapcornsAnalytics.setUserId(userId : "") | ||
``` | ||
|
||
## IMPORTANT !!!!! | ||
|
||
If you are using Revenuecat and Firebase as a receipt validation then you need also set Revenuecat userId because we are also getting logs from Revenuecat webhook . | ||
|
||
So checking authentication everytime user goes into app might be a good idea with this function | ||
|
||
``` | ||
func checkAuth(){ | ||
let cUser = Auth.auth().currentUser | ||
if(cUser != nil){ | ||
PapcornsAnalytics.setUserId(userId: cUser!.uid) | ||
Purchases.shared.identify(cUser!.uid, { (info, error) in | ||
if let e = error { | ||
print("Sign in error: \(e.localizedDescription)") | ||
} | ||
}) | ||
self.continueToSomething() | ||
}else{ | ||
Auth.auth().signInAnonymously { (result, err) in | ||
PapcornsAnalytics.setUserId(userId: (result?.user.uid)!) | ||
Purchases.shared.identify((result?.user.uid)!, { (info, error) in | ||
if let e = error { | ||
print("Sign in error: \(e.localizedDescription)") | ||
} | ||
}) | ||
self.continueToSomething() | ||
} | ||
} | ||
} | ||
``` | ||
|
||
# Tracking Screens | ||
|
||
In `viewDidAppear` function of your viewcontroller call `PapcornsAnalytics.logScreen` with parameters [String:Any] , if there is no parameter then leave it with blank dictionary which is [:] | ||
|
||
Setting a screenName parameter has a naming convention which is to put you context name first and then put "Screen" on top of it . For example if i am in HomeViewController log screen with name "HomeScreen". In log screen event naming start with uppercase letter | ||
|
||
``` | ||
override func viewDidAppear(_ animated: Bool) { | ||
super.viewDidAppear(animated) | ||
PapcornsAnalytics.logScreen(screenName: "XScreen", screenParameters: [:]) | ||
} | ||
``` | ||
|
||
# Tracking Events | ||
|
||
Call `PapcornsAnalytics.logEvent` with parameters [String:Any] whenever you need to trigger an event like in app purchases or signups etc.. , if there is no parameter then leave it with blank dictionary which is [:] .In event naming convension start with lowercased letter | ||
|
||
``` | ||
PapcornsAnalytics.logEvent(eventName: "effectTapped", eventParameters: | ||
[ | ||
"effectName" : "Harry Potter", | ||
"effectId" : "1sae1123asgasr" | ||
] | ||
) | ||
OR | ||
PapcornsAnalytics.logEvent(eventName: "weekly_trial_bought", eventParameters: [:]) | ||
``` | ||
|