Get Started: Unity¶
Install Unity Package¶
Download the latest release version of Repro-Unity-SDK.
Import
Repro.unitypackage
from Asset > Import Package > Custom Package... to your Unity application.
On old version of Unity, build errors in regard to AndroidManifest.xml merging could occur. In such a case please refer to this document.
CommandInvokationFailure: Unable to merge android manifests. See the Console for more details.
/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir="/Users/john/Library/Android/sdk.old/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity5.4.5/PlaybackEngines/AndroidPlayer/Tools/sdktools.jar" -
stderr[
]
stdout[
[Temp/StagingArea/AndroidManifest-main.xml:25, /Users/john/sample/unity5/Temp/StagingArea/android-libraries/repro-android-sdk-2.7.9/AndroidManifest.xml:11] Skipping identical /manifest/application/receiver[@name=com.sample.notification.IntentHandler] element.
Warning: [Temp/StagingArea/AndroidManifest-main.xml:31, /Users/john/sample/unity5/Temp/StagingArea/android-libraries/repro-android-sdk-2.7.9/AndroidManifest.xml:3] Main manifest has <uses-sdk android:targetSdkVersion='25'> but library uses targetSdkVersion='26'
]
Specify Application Class (Android)¶
Note
This step is required only when the target platform is Android.
If you are not using your own custom Application class:
Set android:name attribute of the application element to io.repro.android.UnityApplication.
+ <application android:name="io.repro.android.UnityApplication" ...
If you are using your own custom Application class:
Copy repro-unity-bridge.jar in the unzipped folder to libs folder of the project.
Also add dependency to repro-unity-bridge.jar to your Project by editing its build.gradle as the following.
dependencies {
...
+ provided fileTree(dir: 'libs', include: ['*.jar'])
...
}
Call
io.repro.android.UnityBridge.setupWithoutToken(Application)
atonCreate
in a custom Application class.
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
...
+ io.repro.android.UnityBridge.setupWithoutToken(this);
...
}
}
Setup¶
Start a new session in your Unity script, and attach it to main camera of first scene.
You can find the YOUR_APP_TOKEN
at SDK Token in SETTINGS > PROJECT SETTINGS > Credentials on the management screen.
using UnityEngine;
public class MyBehaviour : MonoBehaviour {
void Start () {
...
// Setup Repro
Repro.Setup ("YOUR_APP_TOKEN");
...
}
}
Information collected by the SDK will be uploaded to the server periodically.
Track event¶
Targeting the right group of users is critical to effectively make analyses or marketing campaigns. By keeping track of user behavior as events, you will be able to choose the right group of users according to your purpose from the dashboard.
Example of targeting user group with events:
If you don't exactly know which events to track in your app, we recommend you to start from tracking the event when each view is displayed.
Example:
@implementation MainViewController
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[Repro track:@"MainViewController" properties:nil];
...
}
class MainViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
Repro.track(event: "MainViewController", properties: [:])
...
}
public class MainActivity extends AppCompatActivity {
@Override
protected void onResume() {
super.onResume();
Repro.track("MainActivity");
...
}
}
#include "ReproCpp.h"
...
ReproCpp::track("Initialized");
Repro.Track ("Initialized");
// Will be written later
class MainScreen extends React.Component {
componentDidMount() {
Repro.track("MainScreen", {});
}
...
}
import Repro from 'react-native-repro';
...
Repro.track("MainScreen", {});
import 'package:repro_flutter/repro.dart';
...
await Repro.track("Initialized");
Set User ID¶
The analytics results you will see in Repro are aggregated per each user. By setting the User ID, you gain the advantages below:
Identify the same user across multiple devices
Target campaigns more accurately
Please see here for more details.
Send push notifications¶
You can send push notifications from Repro's dashboard as well as using the API. Please refer to this document when implementing push notification.
Next...¶
For more details of other available features, please see below.