or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-sdk.mdin-app-messages.mdindex.mdlive-activities.mdlocation.mdnotifications.mdpush-subscription.mdsession.mduser-management.md

core-sdk.mddocs/

0

# Core SDK Functions

1

2

Essential SDK initialization and configuration functions for app startup and user lifecycle management.

3

4

## Capabilities

5

6

### SDK Initialization

7

8

Initialize the OneSignal SDK with your application ID. This must be called during app startup.

9

10

```typescript { .api }

11

/**

12

* Initializes the OneSignal SDK. This should be called during startup of the application.

13

* @param appId - Your OneSignal application ID

14

*/

15

function initialize(appId: string): void;

16

```

17

18

**Usage Example:**

19

20

```typescript

21

import { OneSignal } from "react-native-onesignal";

22

23

// Initialize during app startup

24

OneSignal.initialize("your-onesignal-app-id");

25

```

26

27

### User Authentication

28

29

Manage user sessions for cross-device user identification and tracking.

30

31

```typescript { .api }

32

/**

33

* If your integration is user-centric, or you want the ability to identify the user beyond

34

* the current device, the login method should be called to identify the user.

35

* @param externalId - External user identifier from your system

36

*/

37

function login(externalId: string): void;

38

39

/**

40

* Once (or if) the user is no longer identifiable in your app (i.e. they logged out),

41

* the logout method should be called.

42

*/

43

function logout(): void;

44

```

45

46

**Usage Examples:**

47

48

```typescript

49

// User logs in - identify them for cross-device tracking

50

OneSignal.login("user123");

51

52

// User logs out - clear identification

53

OneSignal.logout();

54

```

55

56

### GDPR Compliance

57

58

Manage privacy consent for GDPR compliance and data protection regulations.

59

60

```typescript { .api }

61

/**

62

* For GDPR users, your application should call this method before setting the App ID.

63

* @param required - Whether privacy consent is required

64

*/

65

function setConsentRequired(required: boolean): void;

66

67

/**

68

* If your application is set to require the user's privacy consent, you can provide this

69

* consent using this method. Indicates whether privacy consent has been granted.

70

* @param granted - Whether consent has been granted

71

*/

72

function setConsentGiven(granted: boolean): void;

73

```

74

75

**Usage Example:**

76

77

```typescript

78

// For GDPR compliance - call before initialize()

79

OneSignal.setConsentRequired(true);

80

81

// After user grants consent

82

OneSignal.setConsentGiven(true);

83

84

// Then initialize

85

OneSignal.initialize("your-app-id");

86

```

87

88

### Debug Configuration

89

90

Configure logging and debugging output for development and troubleshooting.

91

92

```typescript { .api }

93

namespace Debug {

94

/**

95

* Enable logging to help debug if you run into an issue setting up OneSignal.

96

* @param nsLogLevel - Sets the logging level to print to the Android LogCat log or Xcode log

97

*/

98

function setLogLevel(nsLogLevel: LogLevel): void;

99

100

/**

101

* Enable logging to help debug if you run into an issue setting up OneSignal.

102

* @param visualLogLevel - Sets the logging level to show as alert dialogs

103

*/

104

function setAlertLevel(visualLogLevel: LogLevel): void;

105

}

106

```

107

108

**Usage Example:**

109

110

```typescript

111

import { OneSignal, LogLevel } from "react-native-onesignal";

112

113

// Enable verbose logging for development

114

OneSignal.Debug.setLogLevel(LogLevel.Verbose);

115

116

// Show errors as alert dialogs

117

OneSignal.Debug.setAlertLevel(LogLevel.Error);

118

```