For the complete documentation index, see llms.txt. This page is also available as Markdown.

Network

1. Check the network connection status (getNetworkStatus)

getNetworkStatusis a function that gets the device’s current network connection status. The return value is NetworkStatus a type that indicates whether the device is connected to the internet and the connection type (Wi‑Fi, mobile data, etc.). The value is one of the following:

  • OFFLINE: Not connected to the internet.

  • WIFI: Connected to Wi‑Fi.

  • 2G: Connected to a 2G network.

  • 3G: Connected to a 3G network.

  • 4G: Connected to a 4G network.

  • 5G: Connected to a 5G network.

  • WWAN: Connected to the internet, but the connection type (Wi‑Fi, 2G–5G) is unknown. This status can only be checked on iOS.

  • UNKNOWN: The internet connection status is unknown. This status can only be checked on Android.

Signature

function getNetworkStatus(): Promise<NetworkStatus>;

Return value

  • Promise<NetworkStatus>

    Returns the network status.

Example

This is an example of getting the network connection status and displaying it on the screen.

Try the sample app

apps-in-toss-examples from the repository with-network-status Download the code, or scan the QR code below to try it yourself.

QR code link: intoss://with-network-status


2. Making HTTP requests

This introduces how to make network requests in Bedrock.

Using the Fetch API

In Bedrock, just like React Native, Fetch APIcan be used for network communication. The Fetch API is a standard web API that makes it easy to implement asynchronous network requests.

The following is an example that uses an API to fetch "to-do list" data and displays a strikethrough when a "to-do" item is completed.

If you watch the example video, clicking the button triggers a network request and the to-do list is displayed on the screen. When a network request occurs, you can check the request and response in the network inspector.

Watch video

Using other libraries

React Native supports XMLHttpRequest API. Therefore, you can also use third-party network libraries that use this API.

For more details, see the official React Native documentationPlease refer to it.


3. Get server time (getServerTime)

getServerTime is an API that gets the current time based on the Toss app server. Because it returns server time (Server Time) , not the device time, it is useful for preventing duplicate reward claims or cheating that can occur through client-side time manipulation.

It can be used for logic where time reliability is important, such as attendance checks, event period validation, determining reward eligibility,and similar cases.

See

  • The returned time is in Unix timestamp (milliseconds) format.

  • In app versions that do not support it, undefinedmay be returned.

  • before use getServerTime.isSupported()as a it is recommended to first check whether the version is supported.

Signature

Return value

  • Promise<number | undefined>

    Returns the current time of the Toss app server in Unix timestamp milliseconds. (e.g., 1705123456789) In unsupported versions, undefinedis returned.

Example

Last updated

Was this helpful?