Identify the subscriber

Glassfy automatically tries to identify the subscriber based on information on the purchases received by the SDK.

The permissions object has two parameters that help to uniquely identify the subscriber:

  • subscriberId : identifies the subscriber and is connected with the purchases from the store. If a user reinstalls an app the subscriberId remains the same. Due to the way app stores work it is not possible to disassociate a subscriber from their AppStore / PlayStore account so this identifier will remain the same. The subscriberId may change if a user without a purchases (or only with consumables purchases) reinstalls the app.
  • installationId: identifies the current installation of the application and is regenerated every time the app is reinstalled or installed on a different device.

How to get the subscriberId and the installationId

They are both associated with a permissions object:

Glassfy.permissions { [weak self] permissions, err in
  if let permissions=permissions {
      let subscriberID = permissions.subscriberId ?? ""
      let installationID = permissions.installationId ?? ""
      [...]
  }
}
Glassfy permissionsWithCompletion:^(GYPermissions *permissions, NSError *error) {
  if (permissions != nil) {
    NSString *subscriberId = permissions.subscriberId;
    NSString *installationId = permissions.installationId;
    [...]
  }
}
try {
  var permission = await Glassfy.permissions();
  var subscriberId = permission.subscriberId;
  var installationId = permission.installationId;
} catch (e) {
  // error
  [...]
}
try {
  const permissions = await Glassfy.permissions()
  const installationId = permissions.installationId;
  const subscriberId = permissions.subscriberId;
} catch (e) {
  // error
  [...]
}
try {
  const permissions = await Glassfy.permissions()
  const installationId = permissions.installationId;
  const subscriberId = permissions.subscriberId;
} catch (e) {
  // error
  [...]
}
Glassfy.permissions { permissions, error ->
    val subscriberId = permissions?.subscriberId
    val installationId = permissions?.installationId
    [...]
  }
Glassfy.permissions(new PermissionsCallback() {
  @Override
  public void onResult(@Nullable Permissions result, @Nullable GlassfyError error) {
    if (result != null) {
      String installationID = result.getInstallationId();
      String subscriberID = result.getSubscriberId();
      [...]
    }
  }
});

Custom identifier

To identify the user you can set a custom identifier that will be included in Webhooks and allows you to share subscriptions among different devices. To disconnect the user pass null to Glassfy.connectCustomSubscriber function.

  • Custom identifier on multiple devices. All the users with the same Custom identifier share the same permissions.
  • Custom identifier on iOS and Android versions of the app. All the users with the same Custom identifier share the same permissions.
  • Custom identifier on iOS and Paddle. All the users with the same Custom identifier share the same permissions.

Connect custom identifier

Glassfy.connectCustomSubscriber("my_custom_identifier") { error in
    // handle error.
}
[Glassfy connectCustomSubscriber:@"my_custom_identifier" withCompletion:nil];
await Glassfy.connectCustomSubscriber("my_custom_identifier");
await Glassfy.connectCustomSubscriber('my_custom_identifier');
await Glassfy.connectCustomSubscriber({ subscriberId: 'my_custom_identifier' });
Glassfy.connectCustomSubscriber("my_custom_identifier") { error ->
    // handle error.
}
Glassfy.connectCustomSubscriber("my_custom_identifier", new ErrorCallback() {
    @Override
    public void onResult(@Nullable GlassfyError error) {
        // handle error.   
    }
});

No custom id

Anonymous IDCustom IDActionPermission APermission B
AunsetInstall
BunsetInstall
AunsetBuy XX
BunsetBuy YXY

Multiple users share the same permission

Anonymous IDCustom IDActionPermission APermission B
AunsetInstall
BunsetInstall
AunsetBuy XX
Auser_1loginX
Buser_1loginXX

Multiple custom ids

Anonymous IDCustom IDActionPermission APermission B
AunsetInstall
BunsetInstall
AunsetBuy XX
Auser_1loginX
Buser_1loginXX
AunsetlogoutX
Anonymous IDCustom IDActionPermission APermission B
AunsetInstall
BunsetInstall
AunsetBuy XX
Auser_1loginX
Buser_1loginXX
BunsetlogoutX

Multiple account purchases

Anonymous IDCustom IDActionPermission APermission B
AunsetInstall
BunsetInstall
AunsetBuy XX
BunsetBuy YXY
Auser_1loginXY
Buser_1loginX YX Y
BunsetlogoutXY
Anonymous IDCustom IDActionPermission APermission B
AunsetInstall
BunsetInstall
AunsetBuy XX
BunsetBuy YXY
Auser_1loginXY
Buser_1loginX YX Y
Auser_1Buy ZX Y ZX Y Z
AunsetlogoutX ZY