Profile Share
To use already associated profiles on multiple devices you can share them.
Create a sharing token (receiving device)
First, the device that is going to receive the Application Profiles needs to present a QRCode that the sharing device is going to scan.
Client requirements
- iOS (Swift)
- Android (Java)
trustfactorClient.createApplicationProfilesShareReceivingToken() { result, correlationId in
switch result {
case .success(let qrCodeImageData): // Data
let image = UIImage(data: qrCodeImageData)
case .failure(let error):
// handle errors
}
}
trustfactorClient.createApplicationProfilesShareReceivingToken(new Result<byte [], Error>() {
@Override
public void onSuccess(byte [] qrCodeImageData, String correlationId) { // Data
Bitmap image = BitmapFactory.decodeByteArray(qrCodeImageData, 0, qrCodeImageData.length);
}
@Override
public void onFailure(Error error, String correlationId) {
// handle errors
}
});
Share profiles (origin device)
The sharing device scans the QRCode presented by the receiving device and sends the Application Profiles
Client requirements
- iOS (Swift)
- Android (Java)
/// to: value from the scanned QRCode
trustfactorClient.shareProfiles(to: <String>, profiles: [<TFApplicationProfile.RawIdentifier>]) { result, correlationId in
switch result {
case .success:
// handle success
case .failure(let error):
// handle errors
}
}
trustfactorClient.shareProfiles(qrCode: <String>, profilesIDs: <List<String>>, new Result<Boolean, Error>() {
@Override
public void onSuccess(Boolean value, String correlationId) {
// value is a boolean we can ignore
}
@Override
public void onFailure(Error error, String correlationId) {
// handle errors
}
});
Associate shared profiles (receiving device)
Client requirements
- iOS (Swift)
- Android (Java)
// retrieve from notification payload
var userInfo: [AnyHashable: Any] = .....
// get push notification type and content
guard case let .receivedShareApplicationProfiles(payload, error) = try trustfactorClient.getPushNotificationContent(for: userInfo) else {
print("Not shared Profiles notification")
}
// make sure payload is set and no errors occured
guard let payload, error == nil else {
// handle error
}
trustfactorClient.associateSharedApplicationProfiles(from: payload) { result, correlationId in
switch result {
case .success(let associationResult):
// handle result
case .failure(let error):
// handle errors
}
}
// retrieve from notification payload
byte[] userInfo: ...
// get push notification type and content
try{
Object content = trustfactorClient.getPushNotificationContent(userInfo: <byte[]>)
} catch(Exception ){
// handle error
}
if (content instanceof ShareApplicationProfiles) {
ShareApplicationProfiles shareData = (ShareApplicationProfiles) content;
// Handle the received share application profiles data
} else {
// Handle the case when the notification is not for shared profiles
}
// make sure payload is set and no errors occured
if(shareData.payload == null || shareData.error != null){
// handle error
}
trustfactorClient.associateSharedApplicationProfiles(shareData.payload: <ShareContractPayload>, new Result<TFProfileAssociationResult, Error>() {
@Override
public void onSuccess(TFProfileAssociationResult result, String correlationId) {
// result type: TFProfileAssociationResult
}
@Override
public void onFailure(Error error, String correlationId) {
// handle errors
}
});