Cordova > Advanced

General

Migrating from batch.userProfile

If you've previously used batch.userProfile, you can easily use Batch User. You will still be able to set a custom region, language or identifier with the new API.

The main difference between Batch User and BatchUserProfile is that you'll now be required to use an editor object in order to make changes, and then save them. This transactional behaviour brings additional thread-safety and better performance.

That way, what used to be:

// Use the user profile to set custom language and data 
batch.userProfile.setLanguage("en"); // Language must be 2 chars, lowercase, ISO 639 formatted
batch.userProfile.setRegion("US"); // Region must be 2 chars, uppercase, ISO 3166 formatted
batch.userProfile.setCustomID("john.doe");

will become this:

batch.user.getEditor()
    .setLanguage("en") // Language must be 2 chars, lowercase, ISO 639 formatted
    .setRegion("US") // Region must be 2 chars, uppercase, ISO 3166 formatted
    .setIdentifier("john.doe")
    .save(); // Don't forget to save the changes!

batch.userProfile is now deprecated, but will continue to work. We still suggest you migrate in the near future, so you can take advantage of the new capabilities.