# Update guide

> Follow the Unity Update Guide to safely upgrade between Tapjoy SDK versions by removing deprecated methods and adopting updated alternatives to prevent integration issues.

This guide describes steps required when updating from one Tapjoy SDK version to another, it's recommended you perform all the steps to prevent any issues or conflicts.

## 14.3.0

We have modified how the connect call works in this version. Previously it looked like this:

```javascript
try {
    let sdkKey = Platform.OS === 'ios' ? 'ios-sdk-key' : 'android-sdk-key'
    let flags: object = {TJC_OPTION_USER_ID: 'userId'};
    await Tapjoy.connect(sdkKey, flags);
} catch (error: any) {
    let errorString = `Tapjoy SDK failed to connect. code: ${error.code}, message: ${error.message}`;
}
```

From 14.3.0, connect similar to the following example:

```javascript
try {
 let sdkKey = Platform.OS === 'ios' ? 'ios-sdk-key' : 'android-sdk-key'
 let flags: object = { TJC_OPTION_USER_ID: 'userId' };
 await Tapjoy.connect(sdkKey, flags, (event: TapjoyEvent) => {
     // Handle Warning
   },
 );

 // Handle Success
} catch (error: any) {
 // Handle Failure
}
```

## 13.4.0

We added a new `connectWarning` callback. This will fire when there is a non-blocking issue during connect, `connectSuccess` will also fire after. Currently this feature will only detect issues with UserId when sent in ConnectFlags.

```javascript
import {
  NativeEventEmitter,
  NativeModules,
} from 'react-native';

const TJ = NativeModules.TapjoyReactNativeSdk;
      const TapjoyEmitter = new NativeEventEmitter(TJ);
      const TapjoyEventType = 'Tapjoy';
      const subscription = TapjoyEmitter.addListener(
        TapjoyEventType,
        (event: TapjoyEvent) => {
          if (event.name === TJConnect.TJC_CONNECT_WARNING) {
            subscription.remove();
            setStatusLabelText(
              `Tapjoy SDK connected with Warning: ErrorCode: ${event.code} ${event.message} `
            );
          }
        }
      );
```

We also added support for User Tags.

```javascript
Tapjoy.addUserTag('');
Tapjoy.removeUserTag('');
Tapjoy.clearUserTags();
```

## 13.2.0

### Connect

We added error code & message parameters to connectFailure callback. The previous callback is now deprecated but still functional.

```javascript
try {
  await Tapjoy.connect(sdkKey, flags);
} catch (error: any) {
  let errorString = `Tapjoy SDK failed to connect. code: ${error.code}, message: ${error.message}`;
} 
```

### Max user level

It's now possible to set the number of levels in your game. It can be set before or after connect.

```javascript
Tapjoy.setMaxLevel(10); 
```

### User segment

You can now set the type of user currently using your app. This can be set before or after connect, or during the session.

```javascript
Tapjoy.setUserSegment(TJSegment.VIP);
Tapjoy.setUserSegment(TJSegment.Payer);
Tapjoy.setUserSegment(TJSegment.NonPayer);
Tapjoy.setUserSegment(TJSegment.Unknown);
```

### Entry point

Before calling *request connect* you can set the entry point. This describes where in the app the placement will be shown. You can choose from one of several preset values.

```javascript
let placement = new TJPlacement("myPlacement");
placement.setEntryPoint(TJEntryPoint.TJEntryPointMainMenu);
placement.requestContent(); 

// Available values
TJEntryPointUnknown
TJEntryPointOther
TJEntryPointMainMenu
TJEntryPointHud
TJEntryPointExit
TJEntryPointFail
TJEntryPointComplete
TJEntryPointInbox
TJEntryPointInit
TJEntryPointStore
```

### Currency

* Get/spend/earn will no longer accept negative values.
* If self-managed currencies call the managed currency API's, an error will be returned.

You can now set the users balance before creating a placement. It must be set before *requestContent*.

```javascript
let placement = new TJPlacement('placementName');
try {
  await placement?.setCurrencyBalance('1234', 100);
} catch (e: any) {
  let code = e.code;
  let message = e.message;
}
```

You can also set the amount of currency a user needs to achieve their goal on each placement.

```javascript
let placement = new TJPlacement('placementName');
try {
await offerwallPlacement?.setRequiredAmount(100, '100');
} catch (e: any) {
  let code = e.code;
  let message = e.message;
} 
```

### User privacy

Updated interface to match the other platforms. Also added support for Android `optOutAdvertisingId` interface.

```javascript
let privacyPolicy = new TJPrivacyPolicy();
privacyPolicy.setSubjectToGDPRStatus(TJStatus.True);
privacyPolicy.setBelowConsentAgeStatus(TJStatus.False);
privacyPolicy.setUserConsentStatus(TJStatus.Unknown);
privacyPolicy.setUSPrivacy('1---');
privacyPolicy.optOutAdvertisingID(false); 
```
