We'll show you how you can use a Server Experience in a mobile application.
Once a Server Experience has been built, you can use it in mobile applications via the Qubit Mobile SDKs.
To fetch an experience, make the following call:
QubitSDK.fetchExperiences(withIds: [$EXPID], onSuccess: { (experiences) in
if let exp = experiences.first {
// list out the payload values
print("Got experience - payload:")
for (key, value) in exp.payload {
print("\(key) -> \(value)")
}
// mark the experience as shown
exp.shown()
}
}, onError: { (error) in
print("Got error: (error.localizedDescription)")
}, preview: false, ignoreSegments: false, variation: nil)
Where:
$EXPID
is the experience Id from app.qubit.comAn array of experiences experiencePayLoads
will be returned. If the experience specified in $EXPID
is live, it will be in the first item in the array. Within that object, the payload field will contain the variable set in the variation.
To preview an experience in development, set the following:
preview
to true
variation
to the variation Id you wish to previewignoreSegments
to true
if you wish to bypass the segmentation logic for preview purposesTo fetch an experience, make the following call:
[QubitSDK fetchExperiencesWithIds:@[@$EXPID] onSuccess:^(NSArray<QBExperienceEntity *> * _Nonnull experiences) {
QBExperienceEntity* firstEntity = experiences.firstObject;
[firstEntity shown]; // mark the experience as shown
} onError:^(NSError * _Nonnull error) {
NSLog(@"%@", error.description);
} preview:false variation:false ignoreSegments:false];
Where:
$EXPID
is the experience Id from app.qubit.comAn array of experiences experiencePayLoads
will be returned. If the experience specified in $EXPID
is live, it will be in the first item in the array. Within that object, the payload field will contain the variable set in the variation.
To preview an experience in development, set the following:
preview
to true
variation
to the variation Id you wish to previewignoreSegments
to true
if you wish to bypass the segmentation logic for preview purposesTo fetch a live experience:
List<Integer> experienceIds = new ArrayList<>();
experienceIds.add($EXPID);
QubitSDK.tracker().getExperiences(
listOfExperienceIds,
experienceList -> {
for (Experience experience : experienceList) {
experience.shown(); // mark the experience as shown
}
return Unit.INSTANCE;
},
throwable -> {
Log.d(TAG, throwable.toString());
return Unit.INSTANCE;
}, $VARID, true, true
);
Where:
$EXPID
is the experience Id from app.qubit.comAn array of experiences experiencePayLoads
will be returned. If the experience specified in $EXPID
is live, it will be in the first item in the array. Within that object, the payload field will contain the variable set in the variation.
To preview an experience in development, set the following:
preview
to true
variation
to the variation Id you wish to previewignoreSegments
to true
if you wish to bypass the segmentation logic for preview purposesList<Integer> experienceIds = new ArrayList<>();
experienceIds.add(123);
QubitSDK.tracker().getExperiences(
experienceIds,
experienceList -> {
for (Experience experience : experienceList) {
experience.shown(); // mark the experience as shown
}
return Unit.INSTANCE;
},
throwable -> {
Log.d(TAG, throwable.toString());
return Unit.INSTANCE;
}, 678, true, false
);
List<Integer> experienceIds = new ArrayList<>();
experienceIds.add(123);
QubitSDK.tracker().getExperiences(
experienceIds,
experienceList -> {
for (Experience experience : experienceList) {
experience.shown(); // mark the experience as shown
}
return Unit.INSTANCE;
},
throwable -> {
Log.d(TAG, throwable.toString());
return Unit.INSTANCE;
}, 678, true, true
);
QubitSDK.tracker().getExperiences(
experienceIdList = listOf($EXPID), // list of experience IDs (integers)
onSuccess = {
experienceList -> experienceList.forEach {
it.shown() // mark the experience as shown
}
},
onError = {
throwable -> Log.e(TAG, "Error: ", throwable)
},
variation = null,
preview = true,
ignoreSegments = true
)
An array of experiences experiencePayLoads will be returned. If the experience specified in $EXPID is live, it will be in the first item in the array. Within that object, the payload field will contain the variable set in the variation.
To preview an experience in development, set the following:
preview: true
variation: variation Id you wish to preview