# React Native SDK 快速入门

通过这个快速简单的示例开始使用 Pushwoosh React Native SDK

## 前提条件

要将 Pushwoosh React Native SDK 集成到您的应用中，您需要满足以下条件：

<TranslatedFragment id="prerequisites-plugins" />

## 下载示例项目

```bash
# Clone the SDK repository and navigate to the example project
git clone https://github.com/Pushwoosh/pushwoosh-react-native-plugin.git

# Navigate to example directory
cd pushwoosh-react-native-plugin/example/demoapp/
```

## 配置项目

安装依赖项：

```bash
npm install
```

打开 **Settings.js** 并更新 `Pushwoosh.init` 调用：

```javascript
Pushwoosh.init({ "pw_appid" : "__YOUR_APP_ID__" });
```

将 `__YOUR_APP_ID__` 替换为您的 **Pushwoosh App Code**。

### iOS

###### 1. 安装依赖项

导航到 ios 目录并安装依赖项：

```bash
cd ios && pod install --repo-update
```

###### 2. 设置 Bundle Identifier

在 Xcode 中打开 **ios/Runner.xcworkspace** 文件。

为每个目标设置 **Bundle Identifier**：

- `Runner`：您的应用的包名。（例如 com.example.pushwoosh）
- `NotificationService`：您的应用的包名加上 `.NotificationServiceExtension`。（例如 com.example.pushwoosh.NotificationServiceExtension）

###### 3. 设置 API Token

在您的 `ios/Runner/Info.plist` 中，将 `Pushwoosh_API_TOKEN` 键设置为 [Pushwoosh Device API Token](/zh/developer/api-reference/api-access-token/#device-api-token)

### Android

###### 1. 设置 google-services.json

将您的 `google-services.json` 文件复制到 **android/app** 目录

###### 2. 设置包名

打开 **android/app/build.gradle** 并将 **applicationId** 设置为您的应用的包名。（例如 `com.example.pushwoosh`）

###### 3. 设置 API Token

打开您的 **android/app/src/main/AndroidManifest.xml** 文件，并在 `<application>` 标签内添加以下元数据：

```xml title="AndroidManifest.xml"
<meta-data android:name="com.pushwoosh.apitoken" android:value="__YOUR_PUSHWOOSH_DEVICE_API_TOKEN__" />
```
将 `__YOUR_PUSHWOOSH_DEVICE_API_TOKEN__` 替换为您的 [Pushwoosh Device API Token](/zh/developer/api-reference/api-access-token/#device-api-token)。

## 运行项目

1. 构建并运行项目。
2. 该应用将有两个选项卡：“Actions” 和 “Settings”。导航到 **Settings** 选项卡。
3. 点击 **Register for Push Notifications** 按钮。
4. 授予推送通知权限。设备将在 Pushwoosh 注册。

## 发送推送通知

返回 Pushwoosh Control Panel 并向您注册的设备[发送推送通知](/zh/product/messaging-channels/push-notifications/send-push-notifications/one-time-push)。