Capacitor SDK quick start
Этот контент еще не доступен на вашем языке.
Get started with the Pushwoosh Capacitor SDK using this quick and simple example
Prerequisites
Anchor link toTo integrate the Pushwoosh Capacitor SDK into your app, you will need the following:
Download the example project
Anchor link toClone the SDK repository:
git clone https://github.com/Pushwoosh/pushwoosh-capacitor-plugin.gitNavigate to the plugin directory:
cd pushwoosh-capacitor-pluginBuild the plugin
Anchor link toBefore running the example app, you need to build the Capacitor plugin.
Install plugin dependencies:
npm iBuild the plugin:
npm run buildConfigure the example app
Anchor link toNavigate to the example app directory:
cd exampleInstall the app dependencies:
npm iBuild the web assets:
npm run buildOpen src/js/example.js and update the Pushwoosh.onDeviceReady call:
Pushwoosh.onDeviceReady({ projectid: "__YOUR_FCM_SENDER_ID__", appid: "__YOUR_APP_CODE__"});Where:
__YOUR_APP_CODE__ is the application code from the Pushwoosh Control Panel. __YOUR_FCM_SENDER_ID__ is the Firebase project number from the Firebase Console.
1. Install CocoaPods dependencies
Anchor link toNavigate to the iOS platform directory and install the CocoaPods dependencies:
cd ios/Apppod install --repo-updatecd ../..2. Sync Capacitor to iOS
Anchor link toAfter installing CocoaPods, sync the Capacitor configuration:
npx cap sync ios3. Open the iOS project
Anchor link toOpen the project in Xcode:
npx cap open ios3. Set the Bundle Identifier
Anchor link toIn Xcode, set the Bundle Identifier to your app’s package name (e.g., com.example.pushwoosh).
5. Add capabilities
Anchor link toTo enable Push Notifications, you need to add certain capabilities.
In the Signing & Capabilities section, add the following capabilities:
Push NotificationsBackground Modes. After adding this capability, check the box forRemote notifications.
6. Set the API Token
Anchor link toOpen ios/App/App/Info.plist in Xcode and add the following entry with your Pushwoosh Device API Token:
<key>Pushwoosh_API_TOKEN</key><string>__YOUR_PUSHWOOSH_DEVICE_API_TOKEN__</string>Android
Anchor link to1. Sync Capacitor to Android
Anchor link toSync the Capacitor configuration to the Android platform:
npx cap sync android2. Setup google-services.json
Anchor link toCopy your google-services.json file to the android/app directory.
3. Set the package name
Anchor link toOpen android/app/build.gradle and set the applicationId to your app’s package name (e.g., com.example.pushwoosh).
4. Set the API Token
Anchor link toOpen your android/app/src/main/AndroidManifest.xml file and add the following metadata inside the <application> tag:
<meta-data android:name="com.pushwoosh.apitoken" android:value="__YOUR_PUSHWOOSH_DEVICE_API_TOKEN__" />Replace __YOUR_PUSHWOOSH_DEVICE_API_TOKEN__ with your Pushwoosh Device API Token.
5. Open the Android project
Anchor link toOpen the project in Android Studio:
npx cap open androidRun the project
Anchor link to- Build and run the project.
- Tap the “Click Me!” button.
- Grant permission for push notifications. The device will be registered with Pushwoosh.
Send a push notification
Anchor link toGo back to the Pushwoosh Control Panel and send a push notification to your registered device.