createViewManagers(ReactApplicationContext reactContext) {
27 | return new ArrayList<>();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/android/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RNOneSignalAndroid
3 |
4 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:metro-react-native-babel-preset'],
3 | };
4 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/.buckconfig:
--------------------------------------------------------------------------------
1 |
2 | [android]
3 | target = Google Inc.:Google APIs:23
4 |
5 | [maven_repositories]
6 | central = https://repo1.maven.org/maven2
7 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: '@react-native-community',
4 | parser: '@typescript-eslint/parser',
5 | plugins: ['@typescript-eslint'],
6 | };
7 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj -text
2 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 |
24 | # Android/IntelliJ
25 | #
26 | build/
27 | .idea
28 | .gradle
29 | local.properties
30 | *.iml
31 |
32 | # Visual Studio Code
33 | #
34 | .vscode/
35 |
36 | # node.js
37 | #
38 | node_modules/
39 | npm-debug.log
40 | yarn-error.log
41 |
42 | # BUCK
43 | buck-out/
44 | \.buckd/
45 | *.keystore
46 | !debug.keystore
47 |
48 | # fastlane
49 | #
50 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
51 | # screenshots whenever they are needed.
52 | # For more information about the recommended setup visit:
53 | # https://docs.fastlane.tools/best-practices/source-control/
54 |
55 | */fastlane/report.xml
56 | */fastlane/Preview.html
57 | */fastlane/screenshots
58 |
59 | # Bundle artifact
60 | *.jsbundle
61 |
62 | # CocoaPods
63 | /ios/Pods/
64 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | bracketSpacing: false,
3 | jsxBracketSameLine: true,
4 | singleQuote: true,
5 | trailingComma: 'all',
6 | };
7 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/__tests__/App-test.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | import 'react-native';
6 | import React from 'react';
7 | import App from '../src/App';
8 |
9 | // Note: test renderer must be required after react-native.
10 | import renderer from 'react-test-renderer';
11 |
12 | it('renders correctly', () => {
13 | renderer.create();
14 | });
15 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/_BUCK:
--------------------------------------------------------------------------------
1 | # To learn about Buck see [Docs](https://buckbuild.com/).
2 | # To run your application with Buck:
3 | # - install Buck
4 | # - `npm start` - to start the packager
5 | # - `cd android`
6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8 | # - `buck install -r android/app` - compile, install and run application
9 | #
10 |
11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12 |
13 | lib_deps = []
14 |
15 | create_aar_targets(glob(["libs/*.aar"]))
16 |
17 | create_jar_targets(glob(["libs/*.jar"]))
18 |
19 | android_library(
20 | name = "all-libs",
21 | exported_deps = lib_deps,
22 | )
23 |
24 | android_library(
25 | name = "app-code",
26 | srcs = glob([
27 | "src/main/java/**/*.java",
28 | ]),
29 | deps = [
30 | ":all-libs",
31 | ":build_config",
32 | ":res",
33 | ],
34 | )
35 |
36 | android_build_config(
37 | name = "build_config",
38 | package = "com.rnonesignalts",
39 | )
40 |
41 | android_resource(
42 | name = "res",
43 | package = "com.rnonesignalts",
44 | res = "src/main/res",
45 | )
46 |
47 | android_binary(
48 | name = "app",
49 | keystore = "//android/keystores:debug",
50 | manifest = "src/main/AndroidManifest.xml",
51 | package_type = "debug",
52 | deps = [
53 | ":app-code",
54 | ],
55 | )
56 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.android.application"
2 |
3 | import com.android.build.OutputFile
4 |
5 | /**
6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7 | * and bundleReleaseJsAndAssets).
8 | * These basically call `react-native bundle` with the correct arguments during the Android build
9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10 | * bundle directly from the development server. Below you can see all the possible configurations
11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the
12 | * `apply from: "../../node_modules/react-native/react.gradle"` line.
13 | *
14 | * project.ext.react = [
15 | * // the name of the generated asset file containing your JS bundle
16 | * bundleAssetName: "index.android.bundle",
17 | *
18 | * // the entry file for bundle generation. If none specified and
19 | * // "index.android.js" exists, it will be used. Otherwise "index.js" is
20 | * // default. Can be overridden with ENTRY_FILE environment variable.
21 | * entryFile: "index.android.js",
22 | *
23 | * // https://reactnative.dev/docs/performance#enable-the-ram-format
24 | * bundleCommand: "ram-bundle",
25 | *
26 | * // whether to bundle JS and assets in debug mode
27 | * bundleInDebug: false,
28 | *
29 | * // whether to bundle JS and assets in release mode
30 | * bundleInRelease: true,
31 | *
32 | * // whether to bundle JS and assets in another build variant (if configured).
33 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
34 | * // The configuration property can be in the following formats
35 | * // 'bundleIn${productFlavor}${buildType}'
36 | * // 'bundleIn${buildType}'
37 | * // bundleInFreeDebug: true,
38 | * // bundleInPaidRelease: true,
39 | * // bundleInBeta: true,
40 | *
41 | * // whether to disable dev mode in custom build variants (by default only disabled in release)
42 | * // for example: to disable dev mode in the staging build type (if configured)
43 | * devDisabledInStaging: true,
44 | * // The configuration property can be in the following formats
45 | * // 'devDisabledIn${productFlavor}${buildType}'
46 | * // 'devDisabledIn${buildType}'
47 | *
48 | * // the root of your project, i.e. where "package.json" lives
49 | * root: "../../",
50 | *
51 | * // where to put the JS bundle asset in debug mode
52 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
53 | *
54 | * // where to put the JS bundle asset in release mode
55 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
56 | *
57 | * // where to put drawable resources / React Native assets, e.g. the ones you use via
58 | * // require('./image.png')), in debug mode
59 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
60 | *
61 | * // where to put drawable resources / React Native assets, e.g. the ones you use via
62 | * // require('./image.png')), in release mode
63 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
64 | *
65 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
66 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
67 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle
68 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
69 | * // for example, you might want to remove it from here.
70 | * inputExcludes: ["android/**", "ios/**"],
71 | *
72 | * // override which node gets called and with what additional arguments
73 | * nodeExecutableAndArgs: ["node"],
74 | *
75 | * // supply additional arguments to the packager
76 | * extraPackagerArgs: []
77 | * ]
78 | */
79 |
80 | project.ext.react = [
81 | enableHermes: false, // clean and rebuild if changing
82 | ]
83 |
84 | apply from: "../../node_modules/react-native/react.gradle"
85 |
86 | /**
87 | * Set this to true to create two separate APKs instead of one:
88 | * - An APK that only works on ARM devices
89 | * - An APK that only works on x86 devices
90 | * The advantage is the size of the APK is reduced by about 4MB.
91 | * Upload all the APKs to the Play Store and people will download
92 | * the correct one based on the CPU architecture of their device.
93 | */
94 | def enableSeparateBuildPerCPUArchitecture = false
95 |
96 | /**
97 | * Run Proguard to shrink the Java bytecode in release builds.
98 | */
99 | def enableProguardInReleaseBuilds = false
100 |
101 | /**
102 | * The preferred build flavor of JavaScriptCore.
103 | *
104 | * For example, to use the international variant, you can use:
105 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
106 | *
107 | * The international variant includes ICU i18n library and necessary data
108 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
109 | * give correct results when using with locales other than en-US. Note that
110 | * this variant is about 6MiB larger per architecture than default.
111 | */
112 | def jscFlavor = 'org.webkit:android-jsc:+'
113 |
114 | /**
115 | * Whether to enable the Hermes VM.
116 | *
117 | * This should be set on project.ext.react and mirrored here. If it is not set
118 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
119 | * and the benefits of using Hermes will therefore be sharply reduced.
120 | */
121 | def enableHermes = project.ext.react.get("enableHermes", false);
122 |
123 | android {
124 | compileSdkVersion rootProject.ext.compileSdkVersion
125 |
126 | compileOptions {
127 | sourceCompatibility JavaVersion.VERSION_1_8
128 | targetCompatibility JavaVersion.VERSION_1_8
129 | }
130 |
131 | defaultConfig {
132 | applicationId "com.rnonesignalts"
133 | minSdkVersion rootProject.ext.minSdkVersion
134 | targetSdkVersion rootProject.ext.targetSdkVersion
135 | versionCode 1
136 | versionName "1.0"
137 | }
138 | splits {
139 | abi {
140 | reset()
141 | enable enableSeparateBuildPerCPUArchitecture
142 | universalApk false // If true, also generate a universal APK
143 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
144 | }
145 | }
146 | signingConfigs {
147 | debug {
148 | storeFile file('debug.keystore')
149 | storePassword 'android'
150 | keyAlias 'androiddebugkey'
151 | keyPassword 'android'
152 | }
153 | }
154 | buildTypes {
155 | debug {
156 | signingConfig signingConfigs.debug
157 | }
158 | release {
159 | // Caution! In production, you need to generate your own keystore file.
160 | // see https://reactnative.dev/docs/signed-apk-android.
161 | signingConfig signingConfigs.debug
162 | minifyEnabled enableProguardInReleaseBuilds
163 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
164 | }
165 | }
166 |
167 | // applicationVariants are e.g. debug, release
168 | applicationVariants.all { variant ->
169 | variant.outputs.each { output ->
170 | // For each separate APK per architecture, set a unique version code as described here:
171 | // https://developer.android.com/studio/build/configure-apk-splits.html
172 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
173 | def abi = output.getFilter(OutputFile.ABI)
174 | if (abi != null) { // null for the universal-debug, universal-release variants
175 | output.versionCodeOverride =
176 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
177 | }
178 |
179 | }
180 | }
181 |
182 | // This is a workaround for problem with multiple occurrences of the same file `coroutines.pro`.
183 | packagingOptions {
184 | exclude 'META-INF/com.android.tools/proguard/coroutines.pro'
185 | exclude 'META-INF/kotlinx_coroutines_core.version'
186 | }
187 | }
188 |
189 | dependencies {
190 | implementation fileTree(dir: "libs", include: ["*.jar"])
191 | //noinspection GradleDynamicVersion
192 | implementation "com.facebook.react:react-native:+" // From node_modules
193 |
194 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
195 | implementation 'com.google.android.gms:play-services-location:[17.0.0, 17.99.99]'
196 |
197 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
198 | exclude group:'com.facebook.fbjni'
199 | }
200 |
201 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
202 | exclude group:'com.facebook.flipper'
203 | exclude group:'com.squareup.okhttp3', module:'okhttp'
204 | }
205 |
206 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
207 | exclude group:'com.facebook.flipper'
208 | }
209 |
210 | if (enableHermes) {
211 | def hermesPath = "../../node_modules/hermes-engine/android/";
212 | debugImplementation files(hermesPath + "hermes-debug.aar")
213 | releaseImplementation files(hermesPath + "hermes-release.aar")
214 | } else {
215 | implementation jscFlavor
216 | }
217 | }
218 |
219 | // Run this once to be able to run the application with BUCK
220 | // puts all compile dependencies into folder libs for BUCK to use
221 | task copyDownloadableDepsToLibs(type: Copy) {
222 | from configurations.compile
223 | into 'libs'
224 | }
225 |
226 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
227 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/build_defs.bzl:
--------------------------------------------------------------------------------
1 | """Helper definitions to glob .aar and .jar targets"""
2 |
3 | def create_aar_targets(aarfiles):
4 | for aarfile in aarfiles:
5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6 | lib_deps.append(":" + name)
7 | android_prebuilt_aar(
8 | name = name,
9 | aar = aarfile,
10 | )
11 |
12 | def create_jar_targets(jarfiles):
13 | for jarfile in jarfiles:
14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15 | lib_deps.append(":" + name)
16 | prebuilt_jar(
17 | name = name,
18 | binary_jar = jarfile,
19 | )
20 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/debug/java/com/rnonesignalts/ReactNativeFlipper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the LICENSE file in the root
5 | * directory of this source tree.
6 | */
7 | package com.rnonesignalts;
8 |
9 | import android.content.Context;
10 | import com.facebook.flipper.android.AndroidFlipperClient;
11 | import com.facebook.flipper.android.utils.FlipperUtils;
12 | import com.facebook.flipper.core.FlipperClient;
13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22 | import com.facebook.react.ReactInstanceManager;
23 | import com.facebook.react.bridge.ReactContext;
24 | import com.facebook.react.modules.network.NetworkingModule;
25 | import okhttp3.OkHttpClient;
26 |
27 | public class ReactNativeFlipper {
28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
29 | if (FlipperUtils.shouldEnableFlipper(context)) {
30 | final FlipperClient client = AndroidFlipperClient.getInstance(context);
31 |
32 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
33 | client.addPlugin(new ReactFlipperPlugin());
34 | client.addPlugin(new DatabasesFlipperPlugin(context));
35 | client.addPlugin(new SharedPreferencesFlipperPlugin(context));
36 | client.addPlugin(CrashReporterPlugin.getInstance());
37 |
38 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
39 | NetworkingModule.setCustomClientBuilder(
40 | new NetworkingModule.CustomClientBuilder() {
41 | @Override
42 | public void apply(OkHttpClient.Builder builder) {
43 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
44 | }
45 | });
46 | client.addPlugin(networkFlipperPlugin);
47 | client.start();
48 |
49 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
50 | // Hence we run if after all native modules have been initialized
51 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
52 | if (reactContext == null) {
53 | reactInstanceManager.addReactInstanceEventListener(
54 | new ReactInstanceManager.ReactInstanceEventListener() {
55 | @Override
56 | public void onReactContextInitialized(ReactContext reactContext) {
57 | reactInstanceManager.removeReactInstanceEventListener(this);
58 | reactContext.runOnNativeModulesQueueThread(
59 | new Runnable() {
60 | @Override
61 | public void run() {
62 | client.addPlugin(new FrescoFlipperPlugin());
63 | }
64 | });
65 | }
66 | });
67 | } else {
68 | client.addPlugin(new FrescoFlipperPlugin());
69 | }
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
14 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/java/com/rnonesignalts/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.rnonesignalts;
2 |
3 | import com.facebook.react.ReactActivity;
4 |
5 | public class MainActivity extends ReactActivity {
6 |
7 | /**
8 | * Returns the name of the main component registered from JavaScript. This is used to schedule
9 | * rendering of the component.
10 | */
11 | @Override
12 | protected String getMainComponentName() {
13 | return "RNOneSignalTS";
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/java/com/rnonesignalts/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.rnonesignalts;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import com.facebook.react.PackageList;
6 | import com.facebook.react.ReactApplication;
7 | import com.facebook.react.ReactInstanceManager;
8 | import com.facebook.react.ReactNativeHost;
9 | import com.facebook.react.ReactPackage;
10 | import com.facebook.soloader.SoLoader;
11 | import java.lang.reflect.InvocationTargetException;
12 | import java.util.List;
13 |
14 | public class MainApplication extends Application implements ReactApplication {
15 |
16 | private final ReactNativeHost mReactNativeHost =
17 | new ReactNativeHost(this) {
18 | @Override
19 | public boolean getUseDeveloperSupport() {
20 | return BuildConfig.DEBUG;
21 | }
22 |
23 | @Override
24 | protected List getPackages() {
25 | @SuppressWarnings("UnnecessaryLocalVariable")
26 | List packages = new PackageList(this).getPackages();
27 | // Packages that cannot be autolinked yet can be added manually here, for example:
28 | // packages.add(new MyReactNativePackage());
29 | return packages;
30 | }
31 |
32 | @Override
33 | protected String getJSMainModuleName() {
34 | return "index";
35 | }
36 | };
37 |
38 | @Override
39 | public ReactNativeHost getReactNativeHost() {
40 | return mReactNativeHost;
41 | }
42 |
43 | @Override
44 | public void onCreate() {
45 | super.onCreate();
46 | SoLoader.init(this, /* native exopackage */ false);
47 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
48 | }
49 |
50 | /**
51 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like
52 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
53 | *
54 | * @param context
55 | * @param reactInstanceManager
56 | */
57 | private static void initializeFlipper(
58 | Context context, ReactInstanceManager reactInstanceManager) {
59 | if (BuildConfig.DEBUG) {
60 | try {
61 | /*
62 | We use reflection here to pick up the class that initializes Flipper,
63 | since Flipper library is not available in release mode
64 | */
65 | Class> aClass = Class.forName("com.rnonesignalts.ReactNativeFlipper");
66 | aClass
67 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
68 | .invoke(null, context, reactInstanceManager);
69 | } catch (ClassNotFoundException e) {
70 | e.printStackTrace();
71 | } catch (NoSuchMethodException e) {
72 | e.printStackTrace();
73 | } catch (IllegalAccessException e) {
74 | e.printStackTrace();
75 | } catch (InvocationTargetException e) {
76 | e.printStackTrace();
77 | }
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/examples/RNOneSignalTS/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/examples/RNOneSignalTS/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/examples/RNOneSignalTS/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/examples/RNOneSignalTS/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/examples/RNOneSignalTS/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/examples/RNOneSignalTS/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/examples/RNOneSignalTS/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/examples/RNOneSignalTS/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/examples/RNOneSignalTS/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/examples/RNOneSignalTS/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RNOneSignalTS
3 |
4 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext {
5 | buildToolsVersion = "29.0.2"
6 | minSdkVersion = 21
7 | compileSdkVersion = 33
8 | targetSdkVersion = 33
9 | }
10 | repositories {
11 | google()
12 | jcenter()
13 | }
14 | dependencies {
15 | classpath("com.android.tools.build:gradle:3.5.3")
16 | // NOTE: Do not place your application dependencies here; they belong
17 | // in the individual module build.gradle files
18 | }
19 | }
20 |
21 | allprojects {
22 | repositories {
23 | mavenLocal()
24 | maven {
25 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
26 | url("$rootDir/../node_modules/react-native/android")
27 | }
28 | maven {
29 | // Android JSC is installed from npm
30 | url("$rootDir/../node_modules/jsc-android/dist")
31 | }
32 |
33 | google()
34 | jcenter()
35 | maven { url 'https://www.jitpack.io' }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | # AndroidX package structure to make it clearer which packages are bundled with the
21 | # Android operating system, and which are packaged with your app's APK
22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
23 | android.useAndroidX=true
24 | # Automatically convert third-party libraries to use AndroidX
25 | android.enableJetifier=true
26 |
27 | # Version of flipper SDK to use with React Native
28 | FLIPPER_VERSION=0.105.0
29 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/examples/RNOneSignalTS/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 | # Determine the Java command to use to start the JVM.
86 | if [ -n "$JAVA_HOME" ] ; then
87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
88 | # IBM's JDK on AIX uses strange locations for the executables
89 | JAVACMD="$JAVA_HOME/jre/sh/java"
90 | else
91 | JAVACMD="$JAVA_HOME/bin/java"
92 | fi
93 | if [ ! -x "$JAVACMD" ] ; then
94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
95 |
96 | Please set the JAVA_HOME variable in your environment to match the
97 | location of your Java installation."
98 | fi
99 | else
100 | JAVACMD="java"
101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
102 |
103 | Please set the JAVA_HOME variable in your environment to match the
104 | location of your Java installation."
105 | fi
106 |
107 | # Increase the maximum file descriptors if we can.
108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
109 | MAX_FD_LIMIT=`ulimit -H -n`
110 | if [ $? -eq 0 ] ; then
111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
112 | MAX_FD="$MAX_FD_LIMIT"
113 | fi
114 | ulimit -n $MAX_FD
115 | if [ $? -ne 0 ] ; then
116 | warn "Could not set maximum file descriptor limit: $MAX_FD"
117 | fi
118 | else
119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
120 | fi
121 | fi
122 |
123 | # For Darwin, add options to specify how the application appears in the dock
124 | if $darwin; then
125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126 | fi
127 |
128 | # For Cygwin or MSYS, switch paths to Windows format before running java
129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132 | JAVACMD=`cygpath --unix "$JAVACMD"`
133 |
134 | # We build the pattern for arguments to be converted via cygpath
135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
136 | SEP=""
137 | for dir in $ROOTDIRSRAW ; do
138 | ROOTDIRS="$ROOTDIRS$SEP$dir"
139 | SEP="|"
140 | done
141 | OURCYGPATTERN="(^($ROOTDIRS))"
142 | # Add a user-defined pattern to the cygpath arguments
143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
145 | fi
146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
147 | i=0
148 | for arg in "$@" ; do
149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
151 |
152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
154 | else
155 | eval `echo args$i`="\"$arg\""
156 | fi
157 | i=`expr $i + 1`
158 | done
159 | case $i in
160 | 0) set -- ;;
161 | 1) set -- "$args0" ;;
162 | 2) set -- "$args0" "$args1" ;;
163 | 3) set -- "$args0" "$args1" "$args2" ;;
164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
170 | esac
171 | fi
172 |
173 | # Escape application args
174 | save () {
175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176 | echo " "
177 | }
178 | APP_ARGS=`save "$@"`
179 |
180 | # Collect all arguments for the java command, following the shell quoting and substitution rules
181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
182 |
183 | exec "$JAVACMD" "$@"
184 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto init
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto init
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :init
68 | @rem Get command-line arguments, handling Windows variants
69 |
70 | if not "%OS%" == "Windows_NT" goto win9xME_args
71 |
72 | :win9xME_args
73 | @rem Slurp the command line arguments.
74 | set CMD_LINE_ARGS=
75 | set _SKIP=2
76 |
77 | :win9xME_args_slurp
78 | if "x%~1" == "x" goto execute
79 |
80 | set CMD_LINE_ARGS=%*
81 |
82 | :execute
83 | @rem Setup the command line
84 |
85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
86 |
87 | @rem Execute Gradle
88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
89 |
90 | :end
91 | @rem End local scope for the variables with windows NT shell
92 | if "%ERRORLEVEL%"=="0" goto mainEnd
93 |
94 | :fail
95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
96 | rem the _cmd.exe /c_ return code!
97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
98 | exit /b 1
99 |
100 | :mainEnd
101 | if "%OS%"=="Windows_NT" endlocal
102 |
103 | :omega
104 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'RNOneSignalTS'
2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
3 | include ':app'
4 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "RNOneSignalTS",
3 | "displayName": "RNOneSignalTS"
4 | }
5 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:metro-react-native-babel-preset'],
3 | };
4 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | import {AppRegistry} from 'react-native';
6 | import App from './src/App';
7 | import {name as appName} from './app.json';
8 |
9 | AppRegistry.registerComponent(appName, () => App);
10 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/OneSignalNotificationServiceExtension/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleDisplayName
8 | OneSignalNotificationServiceExtension
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE)
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | NSExtension
24 |
25 | NSExtensionPointIdentifier
26 | com.apple.usernotifications.service
27 | NSExtensionPrincipalClass
28 | NotificationService
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/OneSignalNotificationServiceExtension/NotificationService.h:
--------------------------------------------------------------------------------
1 | //
2 | // NotificationService.h
3 | // OneSignalNotificationServiceExtension
4 | //
5 | // Created by Rodrigo Gomez-Palacio on 12/15/20.
6 | //
7 |
8 | #import
9 |
10 | @interface NotificationService : UNNotificationServiceExtension
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/OneSignalNotificationServiceExtension/NotificationService.m:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #import "NotificationService.h"
4 |
5 | @interface NotificationService ()
6 |
7 | @property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
8 | @property (nonatomic, strong) UNNotificationRequest *receivedRequest;
9 | @property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
10 |
11 | @end
12 |
13 | @implementation NotificationService
14 |
15 | - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
16 | self.receivedRequest = request;
17 | self.contentHandler = contentHandler;
18 | self.bestAttemptContent = [request.content mutableCopy];
19 |
20 | [OneSignal didReceiveNotificationExtensionRequest:self.receivedRequest withMutableNotificationContent:self.bestAttemptContent withContentHandler:self.contentHandler];
21 | }
22 |
23 | - (void)serviceExtensionTimeWillExpire {
24 | // Called just before the extension will be terminated by the system.
25 | // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
26 |
27 | [OneSignal serviceExtensionTimeWillExpireRequest:self.receivedRequest withMutableNotificationContent:self.bestAttemptContent];
28 |
29 | self.contentHandler(self.bestAttemptContent);
30 | }
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/Podfile:
--------------------------------------------------------------------------------
1 | require_relative '../node_modules/react-native/scripts/react_native_pods'
2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
3 |
4 | platform :ios, '11.0'
5 |
6 | target 'RNOneSignalTS' do
7 | config = use_native_modules!
8 |
9 | use_react_native!(:path => config["reactNativePath"])
10 |
11 | target 'RNOneSignalTSTests' do
12 | inherit! :complete
13 | # Pods for testing
14 | end
15 |
16 | # Enables Flipper.
17 | #
18 | # Note that if you have use_frameworks! enabled, Flipper will not work and
19 | # you should disable these next few lines.
20 | # use_flipper!
21 | # post_install do |installer|
22 | # flipper_post_install(installer)
23 | # end
24 | end
25 |
26 | target 'RNOneSignalWidgetExtension' do
27 | pod 'OneSignalXCFramework', '>= 5.0.2', '< 6.0.0'
28 | end
29 |
30 | target 'RNOneSignalTS-tvOS' do
31 | # Pods for RNOneSignalTS-tvOS
32 |
33 | target 'RNOneSignalTS-tvOSTests' do
34 | inherit! :search_paths
35 | # Pods for testing
36 | end
37 | end
38 |
39 | post_install do |installer|
40 | installer.pods_project.targets.each do |target|
41 | target.build_configurations.each do |config|
42 | config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
43 | end
44 | end
45 | end
46 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTS-tvOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | NSAppTransportSecurity
26 |
27 | NSExceptionDomains
28 |
29 | localhost
30 |
31 | NSExceptionAllowsInsecureHTTPLoads
32 |
33 |
34 |
35 |
36 | NSLocationWhenInUseUsageDescription
37 |
38 | UILaunchStoryboardName
39 | LaunchScreen
40 | UIRequiredDeviceCapabilities
41 |
42 | armv7
43 |
44 | UISupportedInterfaceOrientations
45 |
46 | UIInterfaceOrientationPortrait
47 | UIInterfaceOrientationLandscapeLeft
48 | UIInterfaceOrientationLandscapeRight
49 |
50 | UIViewControllerBasedStatusBarAppearance
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTS-tvOSTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTS.xcodeproj/xcshareddata/xcschemes/RNOneSignalTS-tvOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
53 |
55 |
61 |
62 |
63 |
64 |
70 |
72 |
78 |
79 |
80 |
81 |
83 |
84 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTS.xcodeproj/xcshareddata/xcschemes/RNOneSignalTS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
53 |
55 |
61 |
62 |
63 |
64 |
70 |
72 |
78 |
79 |
80 |
81 |
83 |
84 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTS.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTS.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTS/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : UIResponder
5 |
6 | @property (nonatomic, strong) UIWindow *window;
7 |
8 | @end
9 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTS/AppDelegate.m:
--------------------------------------------------------------------------------
1 | #import "AppDelegate.h"
2 |
3 | #import
4 | #import
5 | #import
6 |
7 | #ifdef FB_SONARKIT_ENABLED
8 | #import
9 | #import
10 | #import
11 | #import
12 | #import
13 | #import
14 |
15 | static void InitializeFlipper(UIApplication *application) {
16 | FlipperClient *client = [FlipperClient sharedClient];
17 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
18 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
19 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
20 | [client addPlugin:[FlipperKitReactPlugin new]];
21 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
22 | [client start];
23 | }
24 | #endif
25 |
26 | @implementation AppDelegate
27 |
28 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
29 | {
30 | #ifdef FB_SONARKIT_ENABLED
31 | InitializeFlipper(application);
32 | #endif
33 |
34 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
35 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
36 | moduleName:@"RNOneSignalTS"
37 | initialProperties:nil];
38 |
39 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
40 |
41 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
42 | UIViewController *rootViewController = [UIViewController new];
43 | rootViewController.view = rootView;
44 | self.window.rootViewController = rootViewController;
45 | [self.window makeKeyAndVisible];
46 | return YES;
47 | }
48 |
49 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
50 | {
51 | #if DEBUG
52 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
53 | #else
54 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
55 | #endif
56 | }
57 |
58 | @end
59 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTS/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "idiom": "iphone",
5 | "size": "29x29",
6 | "scale": "2x"
7 | },
8 | {
9 | "idiom": "iphone",
10 | "size": "29x29",
11 | "scale": "3x"
12 | },
13 | {
14 | "idiom": "iphone",
15 | "size": "40x40",
16 | "scale": "2x"
17 | },
18 | {
19 | "idiom": "iphone",
20 | "size": "40x40",
21 | "scale": "3x"
22 | },
23 | {
24 | "idiom": "iphone",
25 | "size": "60x60",
26 | "scale": "2x"
27 | },
28 | {
29 | "idiom": "iphone",
30 | "size": "60x60",
31 | "scale": "3x"
32 | }
33 | ],
34 | "info": {
35 | "version": 1,
36 | "author": "xcode"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTS/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info": {
3 | "version": 1,
4 | "author": "xcode"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | RNOneSignalTS
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSRequiresIPhoneOS
26 |
27 | NSAppTransportSecurity
28 |
29 | NSAllowsArbitraryLoads
30 |
31 | NSExceptionDomains
32 |
33 | localhost
34 |
35 | NSExceptionAllowsInsecureHTTPLoads
36 |
37 |
38 |
39 |
40 | NSLocationAlwaysAndWhenInUseUsageDescription
41 | Your message goes here
42 | NSLocationAlwaysUsageDescription
43 | Your message goes here
44 | NSLocationUsageDescription
45 | Your message goes here
46 | NSLocationWhenInUseUsageDescription
47 | Your message goes here
48 | NSSupportsLiveActivities
49 |
50 | UIBackgroundModes
51 |
52 | remote-notification
53 | location
54 |
55 | UILaunchStoryboardName
56 | LaunchScreen
57 | UIRequiredDeviceCapabilities
58 |
59 | armv7
60 |
61 | UISupportedInterfaceOrientations
62 |
63 | UIInterfaceOrientationPortrait
64 | UIInterfaceOrientationLandscapeLeft
65 | UIInterfaceOrientationLandscapeRight
66 |
67 | UIViewControllerBasedStatusBarAppearance
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTS/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
25 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTS/RNOneSignalTS.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | aps-environment
6 | development
7 | com.apple.security.app-sandbox
8 |
9 | com.apple.security.network.client
10 |
11 | com.apple.security.personal-information.location
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTS/main.m:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char * argv[]) {
6 | @autoreleasepool {
7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTSTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalTSTests/RNOneSignalTSTests.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #import
5 | #import
6 |
7 | #define TIMEOUT_SECONDS 600
8 | #define TEXT_TO_LOOK_FOR @"Welcome to React"
9 |
10 | @interface RNOneSignalTSTests : XCTestCase
11 |
12 | @end
13 |
14 | @implementation RNOneSignalTSTests
15 |
16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
17 | {
18 | if (test(view)) {
19 | return YES;
20 | }
21 | for (UIView *subview in [view subviews]) {
22 | if ([self findSubviewInView:subview matching:test]) {
23 | return YES;
24 | }
25 | }
26 | return NO;
27 | }
28 |
29 | - (void)testRendersWelcomeScreen
30 | {
31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
33 | BOOL foundElement = NO;
34 |
35 | __block NSString *redboxError = nil;
36 | #ifdef DEBUG
37 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
38 | if (level >= RCTLogLevelError) {
39 | redboxError = message;
40 | }
41 | });
42 | #endif
43 |
44 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
45 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
46 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
47 |
48 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
49 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
50 | return YES;
51 | }
52 | return NO;
53 | }];
54 | }
55 |
56 | #ifdef DEBUG
57 | RCTSetLogFunction(RCTDefaultLogFunction);
58 | #endif
59 |
60 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
61 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
62 | }
63 |
64 |
65 | @end
66 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalWidget/Assets.xcassets/AccentColor.colorset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "colors" : [
3 | {
4 | "idiom" : "universal"
5 | }
6 | ],
7 | "info" : {
8 | "author" : "xcode",
9 | "version" : 1
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalWidget/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "platform" : "ios",
6 | "size" : "1024x1024"
7 | }
8 | ],
9 | "info" : {
10 | "author" : "xcode",
11 | "version" : 1
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalWidget/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "colors" : [
3 | {
4 | "idiom" : "universal"
5 | }
6 | ],
7 | "info" : {
8 | "author" : "xcode",
9 | "version" : 1
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalWidget/Assets.xcassets/onesignaldemo.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x"
10 | },
11 | {
12 | "filename" : "onesignal-logo.png",
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "author" : "xcode",
19 | "version" : 1
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalWidget/Assets.xcassets/onesignaldemo.imageset/onesignal-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/examples/RNOneSignalTS/ios/RNOneSignalWidget/Assets.xcassets/onesignaldemo.imageset/onesignal-logo.png
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalWidget/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSExtension
6 |
7 | NSExtensionPointIdentifier
8 | com.apple.widgetkit-extension
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalWidget/RNOneSignalWidgetBundle.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RNOneSignalWidgetBundle.swift
3 | // RNOneSignalWidget
4 | //
5 | // Created by Brian Smith on 4/26/24.
6 | //
7 |
8 | import WidgetKit
9 | import SwiftUI
10 |
11 | #if !targetEnvironment(macCatalyst)
12 | @main
13 | struct RNOneSignalWidgetBundle: WidgetBundle {
14 | var body: some Widget {
15 | RNOneSignalWidgetLiveActivity()
16 | }
17 | }
18 | #endif
19 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalWidget/RNOneSignalWidgetLiveActivity.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RNOneSignalWidgetLiveActivity.swift
3 | // RNOneSignalWidget
4 | //
5 | // Created by Brian Smith on 4/26/24.
6 | //
7 |
8 | #if !targetEnvironment(macCatalyst)
9 | import ActivityKit
10 | import WidgetKit
11 | import SwiftUI
12 | import OneSignalLiveActivities
13 |
14 | struct RNOneSignalWidgetLiveActivity: Widget {
15 | var body: some WidgetConfiguration {
16 | ActivityConfiguration(for: DefaultLiveActivityAttributes.self) { context in
17 | // Lock screen/banner UI goes here\VStack(alignment: .leading) {
18 | VStack {
19 | Spacer()
20 | Text("REACT: " + (context.attributes.data["title"]?.asString() ?? "")).font(.headline)
21 | Spacer()
22 | HStack {
23 | Spacer()
24 | Label {
25 | Text(context.state.data["message"]?.asDict()?["en"]?.asString() ?? "")
26 | } icon: {
27 | Image("onesignaldemo")
28 | .resizable()
29 | .scaledToFit()
30 | .frame(width: 40.0, height: 40.0)
31 | }
32 | Spacer()
33 | }
34 | Text("INT: " + String(context.state.data["intValue"]?.asInt() ?? 0))
35 | Text("DBL: " + String(context.state.data["doubleValue"]?.asDouble() ?? 0.0))
36 | Text("BOL: " + String(context.state.data["boolValue"]?.asBool() ?? false))
37 | Spacer()
38 | }
39 | .activitySystemActionForegroundColor(.black)
40 | .activityBackgroundTint(.white)
41 | } dynamicIsland: { _ in
42 | DynamicIsland {
43 | // Expanded UI goes here. Compose the expanded UI through
44 | // various regions, like leading/trailing/center/bottom
45 | DynamicIslandExpandedRegion(.leading) {
46 | Text("Leading")
47 | }
48 | DynamicIslandExpandedRegion(.trailing) {
49 | Text("Trailing")
50 | }
51 | DynamicIslandExpandedRegion(.bottom) {
52 | Text("Bottom")
53 | // more content
54 | }
55 | } compactLeading: {
56 | Text("L")
57 | } compactTrailing: {
58 | Text("T")
59 | } minimal: {
60 | Text("Min")
61 | }
62 | .widgetURL(URL(string: "http://www.apple.com"))
63 | .keylineTint(Color.red)
64 | }
65 | }
66 | }
67 | #endif
68 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/ios/RNOneSignalWidgetExtension.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.network.client
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/metro.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Metro configuration for React Native
3 | * https://github.com/facebook/react-native
4 | *
5 | * @format
6 | */
7 |
8 | module.exports = {
9 | transformer: {
10 | getTransformOptions: async () => ({
11 | transform: {
12 | experimentalImportSupport: false,
13 | inlineRequires: false,
14 | },
15 | }),
16 | },
17 | };
18 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "RNOneSignalTS",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "android": "react-native run-android",
7 | "ios": "react-native run-ios",
8 | "start": "react-native start",
9 | "test": "jest",
10 | "lint": "eslint . --ext .js,.jsx,.ts,.tsx"
11 | },
12 | "dependencies": {
13 | "@react-native-material/core": "^1.3.7",
14 | "react": "17.0.1",
15 | "react-native": "0.64.4",
16 | "react-native-onesignal": "file:../../"
17 | },
18 | "devDependencies": {
19 | "@babel/core": "^7.8.4",
20 | "@babel/runtime": "^7.8.4",
21 | "@react-native-community/eslint-config": "^1.1.0",
22 | "@types/jest": "^25.2.3",
23 | "@types/react-native": "^0.64.4",
24 | "@types/react-test-renderer": "^16.9.2",
25 | "@typescript-eslint/eslint-plugin": "^2.27.0",
26 | "@typescript-eslint/parser": "^2.27.0",
27 | "babel-jest": "^25.1.0",
28 | "eslint": "^6.5.1",
29 | "jest": "^25.1.0",
30 | "metro-react-native-babel-preset": "^0.59.0",
31 | "react-test-renderer": "17.0.1",
32 | "typescript": "^3.8.3"
33 | },
34 | "jest": {
35 | "preset": "react-native",
36 | "moduleFileExtensions": [
37 | "ts",
38 | "tsx",
39 | "js",
40 | "jsx",
41 | "json",
42 | "node"
43 | ]
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/src/App.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | * Sample React Native App
3 | * https://github.com/facebook/react-native
4 | *
5 | * Generated with the TypeScript template
6 | * https://github.com/react-native-community/react-native-template-typescript
7 | *
8 | * @format
9 | */
10 |
11 | import React from 'react';
12 | import {
13 | SafeAreaView,
14 | StyleSheet,
15 | ScrollView,
16 | View,
17 | StatusBar,
18 | } from 'react-native';
19 |
20 | import {Colors} from 'react-native/Libraries/NewAppScreen';
21 | import OSDemo from './OSDemo';
22 |
23 | declare const global: {HermesInternal: null | {}};
24 |
25 | const App = () => {
26 | return (
27 | <>
28 |
29 |
30 |
31 |
32 | >
33 | );
34 | };
35 |
36 | const styles = StyleSheet.create({
37 | body: {
38 | flex: 1,
39 | backgroundColor: Colors.white,
40 | padding: 10,
41 | },
42 | });
43 |
44 | export default App;
45 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/src/Helpers.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import {
3 | View,
4 | StyleSheet,
5 | Platform,
6 | KeyboardAvoidingView,
7 | TextInput,
8 | } from 'react-native';
9 | import {Button} from '@react-native-material/core';
10 |
11 | const disabledColor = '#BEBEBE';
12 |
13 | export const renderButtonView = (name: string, callback: Function) => {
14 | return (
15 |
16 |
24 | );
25 | };
26 |
27 | export const renderFieldView = (
28 | name: string,
29 | value: string,
30 | callback: (text: string) => void,
31 | ) => {
32 | return (
33 |
43 |
56 |
57 | );
58 | };
59 |
60 | const styles = StyleSheet.create({
61 | buttonContainer: {
62 | flexDirection: 'column',
63 | overflow: 'hidden',
64 | borderRadius: 10,
65 | marginVertical: 10,
66 | marginHorizontal: 10,
67 | },
68 | textInput: {
69 | marginHorizontal: 10,
70 | height: 40,
71 | },
72 | });
73 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/src/OSConsole.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | * Sample React Native App
3 | * https://github.com/facebook/react-native
4 | *
5 | * Generated with the TypeScript template
6 | * https://github.com/react-native-community/react-native-template-typescript
7 | *
8 | * @format
9 | */
10 |
11 | import React from 'react';
12 | import {
13 | SafeAreaView,
14 | StyleSheet,
15 | ScrollView,
16 | View,
17 | Text,
18 | Platform,
19 | } from 'react-native';
20 |
21 | import {Colors} from 'react-native/Libraries/NewAppScreen';
22 |
23 | export interface Props {
24 | value: string;
25 | }
26 |
27 | export interface State {}
28 |
29 | class OSConsole extends React.Component {
30 | constructor(props: Props) {
31 | super(props);
32 | }
33 |
34 | scrollToEnd = () => {
35 | this.scrollView.scrollToEnd({animated: true});
36 | };
37 |
38 | render() {
39 | return (
40 |
41 | {
45 | this.scrollView = scrollView;
46 | }}
47 | onContentSizeChange={() => this.scrollToEnd()}
48 | >
49 |
50 |
55 | {this.props.value}
56 |
57 |
58 |
59 |
60 | );
61 | }
62 | }
63 |
64 | const styles = StyleSheet.create({
65 | scrollView: {
66 | backgroundColor: Colors.lighter,
67 | },
68 | body: {
69 | backgroundColor: 'grey',
70 | flex: 1,
71 | flexGrow: 1,
72 | flexDirection: 'row',
73 | },
74 | console: {
75 | flexWrap: 'wrap',
76 | padding: 10,
77 | flexDirection: 'row',
78 | },
79 | textIOS: {
80 | fontFamily: 'Courier',
81 | flex: 1,
82 | flexWrap: 'wrap',
83 | fontSize: 10,
84 | },
85 | textAndroid: {
86 | flex: 1,
87 | flexWrap: 'wrap',
88 | fontSize: 10,
89 | },
90 | });
91 |
92 | export default OSConsole;
93 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/src/OSDemo.tsx:
--------------------------------------------------------------------------------
1 | import {LogLevel, OneSignal} from 'react-native-onesignal';
2 | import * as React from 'react';
3 | import {Alert, StyleSheet, View, ScrollView, SafeAreaView} from 'react-native';
4 | import OSButtons from './OSButtons';
5 | import OSConsole from './OSConsole';
6 | import {renderButtonView} from './Helpers';
7 | import {TextInput, Text} from '@react-native-material/core';
8 |
9 | const APP_ID = '77e32082-ea27-42e3-a898-c72e141824ef';
10 |
11 | export interface Props {
12 | name: string;
13 | }
14 |
15 | export interface State {
16 | name: string;
17 | consoleValue: string;
18 | inputValue: string;
19 | }
20 |
21 | class OSDemo extends React.Component {
22 | constructor(props: Props) {
23 | super(props);
24 |
25 | this.state = {
26 | name: props.name,
27 | inputValue: '',
28 | consoleValue: '',
29 | };
30 | }
31 |
32 | async componentDidMount() {
33 | OneSignal.initialize(APP_ID);
34 | OneSignal.Debug.setLogLevel(LogLevel.Verbose);
35 |
36 | OneSignal.LiveActivities.setupDefault();
37 | // OneSignal.LiveActivities.setupDefault({
38 | // enablePushToStart: false,
39 | // enablePushToUpdate: true,
40 | // });
41 |
42 | OneSignal.Notifications.addEventListener(
43 | 'foregroundWillDisplay',
44 | (event) => {
45 | this.OSLog('OneSignal: notification will show in foreground:', event);
46 | let notif = event.getNotification();
47 |
48 | const cancelButton = {
49 | text: 'Cancel',
50 | onPress: () => {
51 | event.preventDefault();
52 | },
53 | style: 'cancel',
54 | };
55 |
56 | const completeButton = {
57 | text: 'Display',
58 | onPress: () => {
59 | event.getNotification().display();
60 | },
61 | };
62 |
63 | Alert.alert(
64 | 'Display notification?',
65 | notif.title,
66 | [cancelButton, completeButton],
67 | {
68 | cancelable: true,
69 | },
70 | );
71 | },
72 | );
73 |
74 | OneSignal.Notifications.addEventListener('click', (event) => {
75 | this.OSLog('OneSignal: notification clicked:', event);
76 | });
77 |
78 | OneSignal.InAppMessages.addEventListener('click', (event) => {
79 | this.OSLog('OneSignal IAM clicked:', event);
80 | });
81 |
82 | OneSignal.InAppMessages.addEventListener('willDisplay', (event) => {
83 | this.OSLog('OneSignal: will display IAM: ', event);
84 | });
85 |
86 | OneSignal.InAppMessages.addEventListener('didDisplay', (event) => {
87 | this.OSLog('OneSignal: did display IAM: ', event);
88 | });
89 |
90 | OneSignal.InAppMessages.addEventListener('willDismiss', (event) => {
91 | this.OSLog('OneSignal: will dismiss IAM: ', event);
92 | });
93 |
94 | OneSignal.InAppMessages.addEventListener('didDismiss', (event) => {
95 | this.OSLog('OneSignal: did dismiss IAM: ', event);
96 | });
97 |
98 | OneSignal.User.pushSubscription.addEventListener(
99 | 'change',
100 | (subscription) => {
101 | this.OSLog('OneSignal: subscription changed:', subscription);
102 | },
103 | );
104 |
105 | OneSignal.Notifications.addEventListener('permissionChange', (granted) => {
106 | this.OSLog('OneSignal: permission changed:', granted);
107 | });
108 |
109 | OneSignal.User.addEventListener('change', (event) => {
110 | this.OSLog('OneSignal: user changed: ', event);
111 | });
112 | }
113 |
114 | OSLog = (message: string, optionalArg: any = null) => {
115 | if (optionalArg !== null) {
116 | message = message + JSON.stringify(optionalArg);
117 | }
118 |
119 | console.log(message);
120 |
121 | let consoleValue;
122 |
123 | if (this.state.consoleValue) {
124 | consoleValue = `${this.state.consoleValue}\n${message}`;
125 | } else {
126 | consoleValue = message;
127 | }
128 | this.setState({consoleValue});
129 | };
130 |
131 | inputChange = (text: string) => {
132 | this.setState({inputValue: text});
133 | };
134 |
135 | render() {
136 | return (
137 |
138 |
139 | OneSignal
140 |
141 |
142 | {renderButtonView('X', () => {
143 | this.setState({consoleValue: ''});
144 | })}
145 |
146 |
151 |
152 |
153 |
157 |
158 |
159 | );
160 | }
161 | }
162 |
163 | // styles
164 | const styles = StyleSheet.create({
165 | container: {
166 | flex: 1,
167 | flexDirection: 'column',
168 | justifyContent: 'flex-start',
169 | alignItems: 'stretch',
170 | backgroundColor: '#fff',
171 | },
172 | header: {
173 | flex: 0.5,
174 | },
175 | scrollView: {
176 | flex: 0.5,
177 | },
178 | title: {
179 | fontSize: 40,
180 | alignSelf: 'center',
181 | paddingVertical: 10,
182 | },
183 | clearButton: {
184 | position: 'absolute',
185 | right: 0,
186 | top: 70,
187 | },
188 | input: {
189 | marginTop: 10,
190 | },
191 | });
192 |
193 | export default OSDemo;
194 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | /* Basic Options */
4 | "target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
5 | "module": "es2015" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
6 | "lib": [
7 | "es6"
8 | ] /* Specify library files to be included in the compilation. */,
9 | "allowJs": true /* Allow javascript files to be compiled. */,
10 | // "checkJs": true, /* Report errors in .js files. */
11 | "jsx": "react-native" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
12 | // "declaration": true, /* Generates corresponding '.d.ts' file. */
13 | // "sourceMap": true, /* Generates corresponding '.map' file. */
14 | // "outFile": "./", /* Concatenate and emit output to single file. */
15 | // "outDir": "./", /* Redirect output structure to the directory. */
16 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
17 | // "removeComments": true, /* Do not emit comments to output. */
18 | "noEmit": true /* Do not emit outputs. */,
19 | // "incremental": true, /* Enable incremental compilation */
20 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */
21 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
22 | "isolatedModules": true /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */,
23 |
24 | /* Strict Type-Checking Options */
25 | "strict": true /* Enable all strict type-checking options. */,
26 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
27 | // "strictNullChecks": true, /* Enable strict null checks. */
28 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */
29 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
30 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
31 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
32 |
33 | /* Additional Checks */
34 | // "noUnusedLocals": true, /* Report errors on unused locals. */
35 | // "noUnusedParameters": true, /* Report errors on unused parameters. */
36 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
37 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
38 |
39 | /* Module Resolution Options */
40 | "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
41 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
42 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
43 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
44 | // "typeRoots": [], /* List of folders to include type definitions from. */
45 | // "types": [], /* Type declaration files to be included in compilation. */
46 | "allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
47 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
48 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
49 |
50 | /* Source Map Options */
51 | // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
52 | // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
53 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
54 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
55 |
56 | /* Experimental Options */
57 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
58 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
59 | },
60 | "exclude": [
61 | "node_modules",
62 | "babel.config.js",
63 | "metro.config.js",
64 | "jest.config.js"
65 | ]
66 | }
67 |
--------------------------------------------------------------------------------
/examples/RNOneSignalTS/update_example:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 |
4 | (cd ../../ && rm -rf dist/ && yarn)
5 |
6 | if [[ "$1" == "--fast" ]]; then
7 | NODE_MODULES_FOLDER=./node_modules/react-native-onesignal
8 | cp -rv ../../dist $NODE_MODULES_FOLDER
9 | cp -rv ../../src $NODE_MODULES_FOLDER
10 | cp -rv ../../ios $NODE_MODULES_FOLDER
11 | cp -rv ../../android $NODE_MODULES_FOLDER
12 | else
13 | yarn remove react-native-onesignal
14 | yarn add file:../../
15 | fi
16 |
--------------------------------------------------------------------------------
/images/1abfb4e-Xcode_create_notification_service_extension_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/images/1abfb4e-Xcode_create_notification_service_extension_2.png
--------------------------------------------------------------------------------
/images/5c47cf5-Xcode_create_notification_service_extension_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/images/5c47cf5-Xcode_create_notification_service_extension_3.png
--------------------------------------------------------------------------------
/images/74a6d44-Xcode_create_notification_service_extension_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/images/74a6d44-Xcode_create_notification_service_extension_1.png
--------------------------------------------------------------------------------
/images/build-settings-search-paths.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/images/build-settings-search-paths.png
--------------------------------------------------------------------------------
/images/linked-libraries.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/images/linked-libraries.png
--------------------------------------------------------------------------------
/ios/RCTOneSignal.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | CA1CC868200FE3C3005B66AA /* RCTOneSignalExtensionService.m in Sources */ = {isa = PBXBuildFile; fileRef = CA1CC867200FE3C3005B66AA /* RCTOneSignalExtensionService.m */; };
11 | CA3D8B582076D83C006F3572 /* RCTOneSignal.h in Headers */ = {isa = PBXBuildFile; fileRef = FDB40CC21C5E4E5500CBF09B /* RCTOneSignal.h */; };
12 | CA3D8B592076D83C006F3572 /* RCTOneSignalExtensionService.h in Headers */ = {isa = PBXBuildFile; fileRef = CA1CC866200FE3C3005B66AA /* RCTOneSignalExtensionService.h */; };
13 | CA3D8B5A2076D84E006F3572 /* RCTOneSignal.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = FDB40CC21C5E4E5500CBF09B /* RCTOneSignal.h */; };
14 | CA3D8B5B2076D84E006F3572 /* RCTOneSignalExtensionService.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CA1CC866200FE3C3005B66AA /* RCTOneSignalExtensionService.h */; };
15 | CA63F32E20ACFD60009AE90F /* UIApplication+RCTOnesignal.m in Sources */ = {isa = PBXBuildFile; fileRef = CA63F32C20ACFD60009AE90F /* UIApplication+RCTOnesignal.m */; };
16 | CAADD42420B378FE0089D086 /* libOneSignal.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CAADD42320B378FD0089D086 /* libOneSignal.a */; };
17 | CAADD42620B379070089D086 /* OneSignal.h in Headers */ = {isa = PBXBuildFile; fileRef = CAADD42520B379060089D086 /* OneSignal.h */; };
18 | CAADD42720B3791A0089D086 /* OneSignal.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CAADD42520B379060089D086 /* OneSignal.h */; };
19 | CACB39D6202D232A00D86CD1 /* RCTOneSignalEventEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = CACB39D5202D232A00D86CD1 /* RCTOneSignalEventEmitter.m */; };
20 | FD2CCC851C772B4200B2B24E /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD2CCC841C772B4200B2B24E /* SystemConfiguration.framework */; };
21 | FDB40CC41C5E4E5500CBF09B /* RCTOneSignal.m in Sources */ = {isa = PBXBuildFile; fileRef = FDB40CC31C5E4E5500CBF09B /* RCTOneSignal.m */; };
22 | /* End PBXBuildFile section */
23 |
24 | /* Begin PBXCopyFilesBuildPhase section */
25 | 3245CDEB1BFEE35C00EABF68 /* Copy Headers */ = {
26 | isa = PBXCopyFilesBuildPhase;
27 | buildActionMask = 2147483647;
28 | dstPath = "include/$(PRODUCT_NAME)";
29 | dstSubfolderSpec = 16;
30 | files = (
31 | CAADD42720B3791A0089D086 /* OneSignal.h in Copy Headers */,
32 | CA3D8B5A2076D84E006F3572 /* RCTOneSignal.h in Copy Headers */,
33 | CA3D8B5B2076D84E006F3572 /* RCTOneSignalExtensionService.h in Copy Headers */,
34 | );
35 | name = "Copy Headers";
36 | runOnlyForDeploymentPostprocessing = 0;
37 | };
38 | /* End PBXCopyFilesBuildPhase section */
39 |
40 | /* Begin PBXFileReference section */
41 | 3245CDED1BFEE35C00EABF68 /* libRCTOneSignal.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTOneSignal.a; sourceTree = BUILT_PRODUCTS_DIR; };
42 | CA1CC866200FE3C3005B66AA /* RCTOneSignalExtensionService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTOneSignalExtensionService.h; sourceTree = ""; };
43 | CA1CC867200FE3C3005B66AA /* RCTOneSignalExtensionService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTOneSignalExtensionService.m; sourceTree = ""; };
44 | CA63F32C20ACFD60009AE90F /* UIApplication+RCTOnesignal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIApplication+RCTOnesignal.m"; sourceTree = ""; };
45 | CAADD42320B378FD0089D086 /* libOneSignal.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libOneSignal.a; sourceTree = ""; };
46 | CAADD42520B379060089D086 /* OneSignal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OneSignal.h; sourceTree = ""; };
47 | CACB39D4202D232A00D86CD1 /* RCTOneSignalEventEmitter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTOneSignalEventEmitter.h; sourceTree = ""; };
48 | CACB39D5202D232A00D86CD1 /* RCTOneSignalEventEmitter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTOneSignalEventEmitter.m; sourceTree = ""; };
49 | FD2CCC841C772B4200B2B24E /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; };
50 | FDB40CC21C5E4E5500CBF09B /* RCTOneSignal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTOneSignal.h; sourceTree = ""; };
51 | FDB40CC31C5E4E5500CBF09B /* RCTOneSignal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTOneSignal.m; sourceTree = ""; };
52 | /* End PBXFileReference section */
53 |
54 | /* Begin PBXFrameworksBuildPhase section */
55 | 3245CDEA1BFEE35C00EABF68 /* Frameworks */ = {
56 | isa = PBXFrameworksBuildPhase;
57 | buildActionMask = 2147483647;
58 | files = (
59 | CAADD42420B378FE0089D086 /* libOneSignal.a in Frameworks */,
60 | FD2CCC851C772B4200B2B24E /* SystemConfiguration.framework in Frameworks */,
61 | );
62 | runOnlyForDeploymentPostprocessing = 0;
63 | };
64 | /* End PBXFrameworksBuildPhase section */
65 |
66 | /* Begin PBXGroup section */
67 | 3245CDE41BFEE35C00EABF68 = {
68 | isa = PBXGroup;
69 | children = (
70 | FD2CCC841C772B4200B2B24E /* SystemConfiguration.framework */,
71 | 3245CDEF1BFEE35C00EABF68 /* RCTOneSignal */,
72 | 3245CDEE1BFEE35C00EABF68 /* Products */,
73 | CA1CC858200FDEFC005B66AA /* Frameworks */,
74 | );
75 | sourceTree = "";
76 | };
77 | 3245CDEE1BFEE35C00EABF68 /* Products */ = {
78 | isa = PBXGroup;
79 | children = (
80 | 3245CDED1BFEE35C00EABF68 /* libRCTOneSignal.a */,
81 | );
82 | name = Products;
83 | sourceTree = "";
84 | };
85 | 3245CDEF1BFEE35C00EABF68 /* RCTOneSignal */ = {
86 | isa = PBXGroup;
87 | children = (
88 | FDB40CC21C5E4E5500CBF09B /* RCTOneSignal.h */,
89 | FDB40CC31C5E4E5500CBF09B /* RCTOneSignal.m */,
90 | CACB39D4202D232A00D86CD1 /* RCTOneSignalEventEmitter.h */,
91 | CACB39D5202D232A00D86CD1 /* RCTOneSignalEventEmitter.m */,
92 | CA1CC866200FE3C3005B66AA /* RCTOneSignalExtensionService.h */,
93 | CA1CC867200FE3C3005B66AA /* RCTOneSignalExtensionService.m */,
94 | CA63F32C20ACFD60009AE90F /* UIApplication+RCTOnesignal.m */,
95 | );
96 | path = RCTOneSignal;
97 | sourceTree = "";
98 | };
99 | CA1CC858200FDEFC005B66AA /* Frameworks */ = {
100 | isa = PBXGroup;
101 | children = (
102 | CAADD42520B379060089D086 /* OneSignal.h */,
103 | CAADD42320B378FD0089D086 /* libOneSignal.a */,
104 | );
105 | name = Frameworks;
106 | sourceTree = "";
107 | };
108 | /* End PBXGroup section */
109 |
110 | /* Begin PBXHeadersBuildPhase section */
111 | CA3D8B572076D824006F3572 /* Headers */ = {
112 | isa = PBXHeadersBuildPhase;
113 | buildActionMask = 2147483647;
114 | files = (
115 | CA3D8B582076D83C006F3572 /* RCTOneSignal.h in Headers */,
116 | CAADD42620B379070089D086 /* OneSignal.h in Headers */,
117 | CA3D8B592076D83C006F3572 /* RCTOneSignalExtensionService.h in Headers */,
118 | );
119 | runOnlyForDeploymentPostprocessing = 0;
120 | };
121 | /* End PBXHeadersBuildPhase section */
122 |
123 | /* Begin PBXNativeTarget section */
124 | 3245CDEC1BFEE35C00EABF68 /* RCTOneSignal */ = {
125 | isa = PBXNativeTarget;
126 | buildConfigurationList = 3245CE011BFEE35C00EABF68 /* Build configuration list for PBXNativeTarget "RCTOneSignal" */;
127 | buildPhases = (
128 | 3245CDE91BFEE35C00EABF68 /* Sources */,
129 | 3245CDEA1BFEE35C00EABF68 /* Frameworks */,
130 | 3245CDEB1BFEE35C00EABF68 /* Copy Headers */,
131 | CA3D8B572076D824006F3572 /* Headers */,
132 | );
133 | buildRules = (
134 | );
135 | dependencies = (
136 | );
137 | name = RCTOneSignal;
138 | productName = RCTOneSignal;
139 | productReference = 3245CDED1BFEE35C00EABF68 /* libRCTOneSignal.a */;
140 | productType = "com.apple.product-type.library.static";
141 | };
142 | /* End PBXNativeTarget section */
143 |
144 | /* Begin PBXProject section */
145 | 3245CDE51BFEE35C00EABF68 /* Project object */ = {
146 | isa = PBXProject;
147 | attributes = {
148 | LastUpgradeCheck = 0730;
149 | ORGANIZATIONNAME = "";
150 | TargetAttributes = {
151 | 3245CDEC1BFEE35C00EABF68 = {
152 | CreatedOnToolsVersion = 6.4;
153 | };
154 | };
155 | };
156 | buildConfigurationList = 3245CDE81BFEE35C00EABF68 /* Build configuration list for PBXProject "RCTOneSignal" */;
157 | compatibilityVersion = "Xcode 3.2";
158 | developmentRegion = English;
159 | hasScannedForEncodings = 0;
160 | knownRegions = (
161 | en,
162 | );
163 | mainGroup = 3245CDE41BFEE35C00EABF68;
164 | productRefGroup = 3245CDEE1BFEE35C00EABF68 /* Products */;
165 | projectDirPath = "";
166 | projectRoot = "";
167 | targets = (
168 | 3245CDEC1BFEE35C00EABF68 /* RCTOneSignal */,
169 | );
170 | };
171 | /* End PBXProject section */
172 |
173 | /* Begin PBXSourcesBuildPhase section */
174 | 3245CDE91BFEE35C00EABF68 /* Sources */ = {
175 | isa = PBXSourcesBuildPhase;
176 | buildActionMask = 2147483647;
177 | files = (
178 | CACB39D6202D232A00D86CD1 /* RCTOneSignalEventEmitter.m in Sources */,
179 | CA63F32E20ACFD60009AE90F /* UIApplication+RCTOnesignal.m in Sources */,
180 | CA1CC868200FE3C3005B66AA /* RCTOneSignalExtensionService.m in Sources */,
181 | FDB40CC41C5E4E5500CBF09B /* RCTOneSignal.m in Sources */,
182 | );
183 | runOnlyForDeploymentPostprocessing = 0;
184 | };
185 | /* End PBXSourcesBuildPhase section */
186 |
187 | /* Begin XCBuildConfiguration section */
188 | 3245CDFF1BFEE35C00EABF68 /* Debug */ = {
189 | isa = XCBuildConfiguration;
190 | buildSettings = {
191 | ALWAYS_SEARCH_USER_PATHS = YES;
192 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
193 | CLANG_CXX_LIBRARY = "libc++";
194 | CLANG_ENABLE_MODULES = YES;
195 | CLANG_ENABLE_OBJC_ARC = YES;
196 | CLANG_WARN_BOOL_CONVERSION = YES;
197 | CLANG_WARN_CONSTANT_CONVERSION = YES;
198 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
199 | CLANG_WARN_EMPTY_BODY = YES;
200 | CLANG_WARN_ENUM_CONVERSION = YES;
201 | CLANG_WARN_INT_CONVERSION = YES;
202 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
203 | CLANG_WARN_UNREACHABLE_CODE = YES;
204 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
205 | COPY_PHASE_STRIP = NO;
206 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
207 | ENABLE_STRICT_OBJC_MSGSEND = YES;
208 | ENABLE_TESTABILITY = YES;
209 | FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/Frameworks";
210 | GCC_C_LANGUAGE_STANDARD = gnu99;
211 | GCC_DYNAMIC_NO_PIC = NO;
212 | GCC_NO_COMMON_BLOCKS = YES;
213 | GCC_OPTIMIZATION_LEVEL = 0;
214 | GCC_PREPROCESSOR_DEFINITIONS = (
215 | "DEBUG=1",
216 | "$(inherited)",
217 | );
218 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
219 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
220 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
221 | GCC_WARN_UNDECLARED_SELECTOR = YES;
222 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
223 | GCC_WARN_UNUSED_FUNCTION = YES;
224 | GCC_WARN_UNUSED_VARIABLE = YES;
225 | HEADER_SEARCH_PATHS = "";
226 | IPHONEOS_DEPLOYMENT_TARGET = 7.0;
227 | MTL_ENABLE_DEBUG_INFO = YES;
228 | ONLY_ACTIVE_ARCH = YES;
229 | SDKROOT = iphoneos;
230 | };
231 | name = Debug;
232 | };
233 | 3245CE001BFEE35C00EABF68 /* Release */ = {
234 | isa = XCBuildConfiguration;
235 | buildSettings = {
236 | ALWAYS_SEARCH_USER_PATHS = YES;
237 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
238 | CLANG_CXX_LIBRARY = "libc++";
239 | CLANG_ENABLE_MODULES = YES;
240 | CLANG_ENABLE_OBJC_ARC = YES;
241 | CLANG_WARN_BOOL_CONVERSION = YES;
242 | CLANG_WARN_CONSTANT_CONVERSION = YES;
243 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
244 | CLANG_WARN_EMPTY_BODY = YES;
245 | CLANG_WARN_ENUM_CONVERSION = YES;
246 | CLANG_WARN_INT_CONVERSION = YES;
247 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
248 | CLANG_WARN_UNREACHABLE_CODE = YES;
249 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
250 | COPY_PHASE_STRIP = NO;
251 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
252 | ENABLE_NS_ASSERTIONS = NO;
253 | ENABLE_STRICT_OBJC_MSGSEND = YES;
254 | FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/Frameworks";
255 | GCC_C_LANGUAGE_STANDARD = gnu99;
256 | GCC_NO_COMMON_BLOCKS = YES;
257 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
258 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
259 | GCC_WARN_UNDECLARED_SELECTOR = YES;
260 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
261 | GCC_WARN_UNUSED_FUNCTION = YES;
262 | GCC_WARN_UNUSED_VARIABLE = YES;
263 | HEADER_SEARCH_PATHS = "";
264 | IPHONEOS_DEPLOYMENT_TARGET = 7.0;
265 | MTL_ENABLE_DEBUG_INFO = NO;
266 | SDKROOT = iphoneos;
267 | VALIDATE_PRODUCT = YES;
268 | };
269 | name = Release;
270 | };
271 | 3245CE021BFEE35C00EABF68 /* Debug */ = {
272 | isa = XCBuildConfiguration;
273 | buildSettings = {
274 | FRAMEWORK_SEARCH_PATHS = (
275 | "$(inherited)",
276 | "$(PROJECT_DIR)/Frameworks/**",
277 | "$(PROJECT_DIR)/**",
278 | "$(PROJECT_DIR)",
279 | );
280 | HEADER_SEARCH_PATHS = (
281 | "$(inherited)",
282 | "$(SRCROOT)/../../react-native/React/**",
283 | );
284 | LIBRARY_SEARCH_PATHS = (
285 | "$(inherited)",
286 | "$(PROJECT_DIR)/**",
287 | "$(PROJECT_DIR)/RCTOneSignal",
288 | "$(PROJECT_DIR)",
289 | );
290 | ONLY_ACTIVE_ARCH = NO;
291 | OTHER_LDFLAGS = "-ObjC";
292 | PRODUCT_NAME = "$(TARGET_NAME)";
293 | SKIP_INSTALL = YES;
294 | };
295 | name = Debug;
296 | };
297 | 3245CE031BFEE35C00EABF68 /* Release */ = {
298 | isa = XCBuildConfiguration;
299 | buildSettings = {
300 | FRAMEWORK_SEARCH_PATHS = (
301 | "$(inherited)",
302 | "$(PROJECT_DIR)/Frameworks/**",
303 | "$(PROJECT_DIR)/**",
304 | "$(PROJECT_DIR)",
305 | );
306 | HEADER_SEARCH_PATHS = (
307 | "$(inherited)",
308 | "$(SRCROOT)/../../react-native/React/**",
309 | );
310 | LIBRARY_SEARCH_PATHS = (
311 | "$(inherited)",
312 | "$(PROJECT_DIR)/**",
313 | "$(PROJECT_DIR)/RCTOneSignal",
314 | "$(PROJECT_DIR)",
315 | );
316 | OTHER_LDFLAGS = "-ObjC";
317 | PRODUCT_NAME = "$(TARGET_NAME)";
318 | SKIP_INSTALL = YES;
319 | };
320 | name = Release;
321 | };
322 | /* End XCBuildConfiguration section */
323 |
324 | /* Begin XCConfigurationList section */
325 | 3245CDE81BFEE35C00EABF68 /* Build configuration list for PBXProject "RCTOneSignal" */ = {
326 | isa = XCConfigurationList;
327 | buildConfigurations = (
328 | 3245CDFF1BFEE35C00EABF68 /* Debug */,
329 | 3245CE001BFEE35C00EABF68 /* Release */,
330 | );
331 | defaultConfigurationIsVisible = 0;
332 | defaultConfigurationName = Release;
333 | };
334 | 3245CE011BFEE35C00EABF68 /* Build configuration list for PBXNativeTarget "RCTOneSignal" */ = {
335 | isa = XCConfigurationList;
336 | buildConfigurations = (
337 | 3245CE021BFEE35C00EABF68 /* Debug */,
338 | 3245CE031BFEE35C00EABF68 /* Release */,
339 | );
340 | defaultConfigurationIsVisible = 0;
341 | defaultConfigurationName = Release;
342 | };
343 | /* End XCConfigurationList section */
344 | };
345 | rootObject = 3245CDE51BFEE35C00EABF68 /* Project object */;
346 | }
347 |
--------------------------------------------------------------------------------
/ios/RCTOneSignal.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/RCTOneSignal/RCTOneSignal.h:
--------------------------------------------------------------------------------
1 |
2 | #if __has_include()
3 | #import
4 | #else
5 | #import "../OneSignalFramework.h"
6 | #endif
7 |
8 | @interface RCTOneSignal : NSObject
9 | + (RCTOneSignal *) sharedInstance;
10 |
11 | @end
12 |
--------------------------------------------------------------------------------
/ios/RCTOneSignal/RCTOneSignal.m:
--------------------------------------------------------------------------------
1 | #if __has_include()
2 | #import
3 | #import
4 | #import
5 | #import
6 | #else
7 | #import "RCTConvert.h"
8 | #import "RCTBridge.h"
9 | #import "RCTEventDispatcher.h"
10 | #import "RCTUtils.h"
11 | #endif
12 |
13 | #import "RCTOneSignal.h"
14 | #import "RCTOneSignalEventEmitter.h"
15 |
16 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0
17 |
18 | #define UIUserNotificationTypeAlert UIRemoteNotificationTypeAlert
19 | #define UIUserNotificationTypeBadge UIRemoteNotificationTypeBadge
20 | #define UIUserNotificationTypeSound UIRemoteNotificationTypeSound
21 | #define UIUserNotificationTypeNone UIRemoteNotificationTypeNone
22 | #define UIUserNotificationType UIRemoteNotificationType
23 |
24 | #endif
25 |
26 | @interface RCTOneSignal ()
27 | @end
28 |
29 | @implementation RCTOneSignal {
30 | BOOL didInitialize;
31 | }
32 |
33 | OSNotificationClickResult* coldStartOSNotificationClickResult;
34 |
35 | + (RCTOneSignal *) sharedInstance {
36 | static dispatch_once_t token = 0;
37 | static id _sharedInstance = nil;
38 | dispatch_once(&token, ^{
39 | _sharedInstance = [[RCTOneSignal alloc] init];
40 | });
41 | return _sharedInstance;
42 | }
43 |
44 | - (void)initOneSignal:(NSDictionary *)launchOptions {
45 |
46 | if (didInitialize)
47 | return;
48 |
49 | OneSignalWrapper.sdkType = @"reactnative";
50 | OneSignalWrapper.sdkVersion = @"050212";
51 | // initialize the SDK with a nil app ID so cold start click listeners can be triggered
52 | [OneSignal initialize:nil withLaunchOptions:launchOptions];
53 | didInitialize = true;
54 | }
55 |
56 | - (void)handleRemoteNotificationOpened:(NSString *)result {
57 | NSDictionary *json = [self jsonObjectWithString:result];
58 |
59 | if (json) {
60 | [self sendEvent:OSEventString(NotificationClicked) withBody:json];
61 | }
62 | }
63 |
64 | - (NSDictionary *)jsonObjectWithString:(NSString *)jsonString {
65 | NSError *jsonError;
66 | NSData *data = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
67 | NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonError];
68 |
69 | if (jsonError) {
70 | return nil;
71 | }
72 |
73 | return json;
74 | }
75 |
76 | - (void)sendEvent:(NSString *)eventName withBody:(NSDictionary *)body {
77 | [RCTOneSignalEventEmitter sendEventWithName:eventName withBody:body];
78 | }
79 |
80 | - (void)onUserStateDidChangeWithState:(OSUserChangedState * _Nonnull)state {
81 | NSString *onesignalId = state.current.onesignalId;
82 | NSString *externalId = state.current.externalId;
83 |
84 | NSMutableDictionary *currentDictionary = [NSMutableDictionary dictionary];
85 |
86 | if (onesignalId.length > 0) {
87 | [currentDictionary setObject:onesignalId forKey:@"onesignalId"];
88 | }
89 | else {
90 | [currentDictionary setObject:[NSNull null] forKey:@"onesignalId"];
91 | }
92 |
93 | if (externalId.length > 0) {
94 | [currentDictionary setObject:externalId forKey:@"externalId"];
95 | }
96 | else {
97 | [currentDictionary setObject:[NSNull null] forKey:@"externalId"];
98 | }
99 |
100 | NSDictionary *result = @{@"current": currentDictionary};
101 |
102 | [self sendEvent:OSEventString(UserStateChanged) withBody:result];
103 | }
104 |
105 | - (void)onPushSubscriptionDidChangeWithState:(OSPushSubscriptionChangedState * _Nonnull)state {
106 | NSMutableDictionary *result = [NSMutableDictionary new];
107 |
108 | //Previous state
109 | NSMutableDictionary *previousObject = [NSMutableDictionary new];
110 | previousObject[@"token"] = (state.previous.token && ![state.previous.token isEqualToString:@""]) ? state.previous.token : [NSNull null];
111 | previousObject[@"id"] = (state.previous.id && ![state.previous.id isEqualToString:@""]) ? state.previous.id : [NSNull null];
112 | previousObject[@"optedIn"] = @(state.previous.optedIn);
113 | result[@"previous"] = previousObject;
114 |
115 | //Current state
116 | NSMutableDictionary *currentObject = [NSMutableDictionary new];
117 | currentObject[@"token"] = (state.current.token && ![state.current.token isEqualToString:@""]) ? state.current.token : [NSNull null];
118 | currentObject[@"id"] = (state.current.id && ![state.current.id isEqualToString:@""]) ? state.current.id : [NSNull null];
119 | currentObject[@"optedIn"] = @(state.current.optedIn);
120 | result[@"current"] = currentObject;
121 |
122 | [self sendEvent:OSEventString(SubscriptionChanged) withBody:result];
123 | }
124 |
125 | - (void)onNotificationPermissionDidChange:(BOOL)permission {
126 | [self sendEvent:OSEventString(PermissionChanged) withBody:@{@"permission": @(permission)}];
127 | }
128 |
129 | - (void)onClickNotification:(OSNotificationClickEvent * _Nonnull)event {
130 | [self sendEvent:OSEventString(NotificationClicked) withBody:[event jsonRepresentation]];
131 | }
132 |
133 | - (void)onClickInAppMessage:(OSInAppMessageClickEvent * _Nonnull)event {
134 | [self sendEvent:OSEventString(InAppMessageClicked) withBody:[event jsonRepresentation]];
135 | }
136 |
137 | - (void)onWillDisplayInAppMessage:(OSInAppMessageWillDisplayEvent * _Nonnull)event {
138 | [self sendEvent:OSEventString(InAppMessageWillDisplay) withBody:[event jsonRepresentation]];
139 | }
140 |
141 | - (void)onDidDisplayInAppMessage:(OSInAppMessageDidDisplayEvent * _Nonnull)event {
142 | [self sendEvent:OSEventString(InAppMessageDidDisplay) withBody:[event jsonRepresentation]];
143 | }
144 |
145 | - (void)onWillDismissInAppMessage:(OSInAppMessageWillDismissEvent * _Nonnull)event {
146 | [self sendEvent:OSEventString(InAppMessageWillDismiss) withBody:[event jsonRepresentation]];
147 | }
148 |
149 | - (void)onDidDismissInAppMessage:(OSInAppMessageDidDismissEvent * _Nonnull)event {
150 | [self sendEvent:OSEventString(InAppMessageDidDismiss) withBody:[event jsonRepresentation]];
151 | }
152 |
153 | - (void)dealloc {
154 | [[NSNotificationCenter defaultCenter] removeObserver:self];
155 | }
156 |
157 | @end
158 |
--------------------------------------------------------------------------------
/ios/RCTOneSignal/RCTOneSignalEventEmitter.h:
--------------------------------------------------------------------------------
1 | #if __has_include()
2 | #import
3 | #import
4 | #import
5 | #import
6 | #import
7 | #elif __has_include("RCTBridgeModule.h")
8 | #import "RCTBridgeModule.h"
9 | #import "RCTEventEmitter.h"
10 | #import "RCTConvert.h"
11 | #import "RCTEventDispatcher.h"
12 | #import "RCTUtils.h"
13 | #endif
14 |
15 | typedef NS_ENUM(NSInteger, OSNotificationEventTypes) {
16 | PermissionChanged,
17 | SubscriptionChanged,
18 | UserStateChanged,
19 | NotificationWillDisplayInForeground,
20 | NotificationClicked,
21 | InAppMessageClicked,
22 | InAppMessageWillDisplay,
23 | InAppMessageDidDisplay,
24 | InAppMessageWillDismiss,
25 | InAppMessageDidDismiss,
26 | };
27 |
28 | #define OSNotificationEventTypesArray @[@"OneSignal-permissionChanged",@"OneSignal-subscriptionChanged",@"OneSignal-userStateChanged",@"OneSignal-notificationWillDisplayInForeground",@"OneSignal-notificationClicked",@"OneSignal-inAppMessageClicked", @"OneSignal-inAppMessageWillDisplay", @"OneSignal-inAppMessageDidDisplay", @"OneSignal-inAppMessageWillDismiss", @"OneSignal-inAppMessageDidDismiss"]
29 |
30 | #define OSEventString(enum) [OSNotificationEventTypesArray objectAtIndex:enum]
31 |
32 | @interface RCTOneSignalEventEmitter : RCTEventEmitter
33 |
34 | + (void)sendEventWithName:(NSString *)name withBody:(NSDictionary *)body;
35 | + (BOOL)hasSetBridge;
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/ios/RCTOneSignal/RCTOneSignalExtensionService.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface RCTOneSignalExtensionService : NSObject
5 | + (void)serviceExtensionTimeWillExpireRequest:(UNNotificationRequest * _Nonnull)request withMutableNotificationContent:(UNMutableNotificationContent * _Nullable)content;
6 | + (void)didReceiveNotificationRequest:(UNNotificationRequest * _Nonnull)request withContent:(UNMutableNotificationContent * _Nullable)content;
7 | + (void)didReceiveNotificationRequest:(UNNotificationRequest * _Nonnull)request withContent:(UNMutableNotificationContent * _Nullable)content withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler;
8 | @end
9 |
--------------------------------------------------------------------------------
/ios/RCTOneSignal/RCTOneSignalExtensionService.m:
--------------------------------------------------------------------------------
1 | #import
2 |
3 |
4 | #import "RCTOneSignalExtensionService.h"
5 |
6 | @implementation RCTOneSignalExtensionService
7 |
8 | //forwards OneSignal notification extension requests
9 | +(void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContent:(UNMutableNotificationContent * _Nullable)content {
10 | [OneSignal didReceiveNotificationExtensionRequest:request withMutableNotificationContent:content];
11 | }
12 |
13 | + (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContent:(UNMutableNotificationContent* _Nullable)content withContentHandler:(void (^)(UNNotificationContent *_Nonnull))contentHandler {
14 | [OneSignal didReceiveNotificationExtensionRequest:request withMutableNotificationContent:content withContentHandler:contentHandler];
15 | }
16 |
17 | +(void)serviceExtensionTimeWillExpireRequest:(UNNotificationRequest *)request withMutableNotificationContent:(UNMutableNotificationContent * _Nullable)content {
18 | [OneSignal serviceExtensionTimeWillExpireRequest:request withMutableNotificationContent:content];
19 | }
20 | @end
21 |
--------------------------------------------------------------------------------
/ios/RCTOneSignal/UIApplication+RCTOnesignal.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface RCTOneSignal
5 | + (RCTOneSignal *) sharedInstance;
6 | - (void)initialize:(nonnull NSString*)newAppId withLaunchOptions:(nullable NSDictionary*)launchOptions;
7 | - (void)initOneSignal:(NSDictionary*)launchOptions;
8 | @end
9 |
10 | @implementation UIApplication(OneSignalReactNative)
11 |
12 | /*
13 | This UIApplication category ensures that OneSignal init() gets called at least one time
14 |
15 | If this did not occur, cold-start notifications would not trigger the React-Native 'opened'
16 | event and other miscellaneous problems would occur.
17 |
18 | First, we swizzle UIApplication's setDelegate method, to get notified when the app delegate
19 | is assigned. Then we swizzle UIApplication's didFinishLaunchingWithOptions() method. When
20 | this method gets called, it initializes the OneSignal SDK with a nil app ID.
21 | */
22 |
23 | // helper method to swizzle instance methods
24 | static void injectSelector(Class newClass, SEL newSel, Class addToClass, SEL makeLikeSel) {
25 | Method newMeth = class_getInstanceMethod(newClass, newSel);
26 | IMP imp = method_getImplementation(newMeth);
27 | const char* methodTypeEncoding = method_getTypeEncoding(newMeth);
28 |
29 | BOOL successful = class_addMethod(addToClass, makeLikeSel, imp, methodTypeEncoding);
30 | if (!successful) {
31 | class_addMethod(addToClass, newSel, imp, methodTypeEncoding);
32 | newMeth = class_getInstanceMethod(addToClass, newSel);
33 |
34 | Method orgMeth = class_getInstanceMethod(addToClass, makeLikeSel);
35 |
36 | method_exchangeImplementations(orgMeth, newMeth);
37 | }
38 | }
39 |
40 | + (void)load {
41 | static dispatch_once_t onceToken;
42 | dispatch_once(&onceToken, ^{
43 | method_exchangeImplementations(class_getInstanceMethod(self, @selector(setDelegate:)), class_getInstanceMethod(self, @selector(setOneSignalReactNativeDelegate:)));
44 | });
45 | }
46 |
47 | - (void) setOneSignalReactNativeDelegate:(id)delegate {
48 | static dispatch_once_t onceToken;
49 | dispatch_once(&onceToken, ^{
50 | Class delegateClass = [delegate class];
51 | injectSelector(self.class, @selector(oneSignalApplication:didFinishLaunchingWithOptions:),
52 | delegateClass, @selector(application:didFinishLaunchingWithOptions:));
53 | [self setOneSignalReactNativeDelegate:delegate];
54 | });
55 | }
56 |
57 | - (BOOL)oneSignalApplication:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
58 | [[RCTOneSignal sharedInstance] initOneSignal:launchOptions];
59 | if ([self respondsToSelector:@selector(oneSignalApplication:didFinishLaunchingWithOptions:)])
60 | return [self oneSignalApplication:application didFinishLaunchingWithOptions:launchOptions];
61 | return YES;
62 | }
63 |
64 | @end
65 |
--------------------------------------------------------------------------------
/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | preset: 'react-native',
3 | moduleDirectories: ['node_modules', 'src'],
4 | modulePathIgnorePatterns: ['examples', 'dist'],
5 | collectCoverage: true,
6 | collectCoverageFrom: ['src/**/*'],
7 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
8 | };
9 |
--------------------------------------------------------------------------------
/metro.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Metro configuration for React Native
3 | * https://github.com/facebook/react-native
4 | *
5 | * @format
6 | */
7 |
8 | module.exports = {
9 | transformer: {
10 | getTransformOptions: async () => ({
11 | transform: {
12 | experimentalImportSupport: false,
13 | inlineRequires: false,
14 | },
15 | }),
16 | },
17 | };
18 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-onesignal",
3 | "version": "5.2.12",
4 | "description": "React Native OneSignal SDK",
5 | "main": "dist/index.js",
6 | "types": "dist/index.d.ts",
7 | "scripts": {
8 | "prepare": "yarn run build",
9 | "build": "tsc",
10 | "lint": "eslint src --ext .js,.jsx,.ts,.tsx; prettier --check src"
11 | },
12 | "dependencies": {
13 | "invariant": "^2.2.2"
14 | },
15 | "devDependencies": {
16 | "@react-native-community/eslint-config": "^1.1.0",
17 | "@types/invariant": "^2.2.2",
18 | "@types/react-native": "^0.66.8",
19 | "eslint": "^7.0.0",
20 | "eslint-config-prettier": "^8.5.0",
21 | "prettier": "^2.7.1",
22 | "typescript": "^3.8.3"
23 | },
24 | "keywords": [
25 | "react-component",
26 | "react-native",
27 | "ios",
28 | "android",
29 | "notifications",
30 | "push",
31 | "apns",
32 | "fcm",
33 | "gcm",
34 | "onesignal"
35 | ],
36 | "bugs": {
37 | "url": "https://github.com/OneSignal/react-native-onesignal/issues"
38 | },
39 | "repository": {
40 | "type": "git",
41 | "url": "https://github.com/OneSignal/react-native-onesignal"
42 | },
43 | "author": "OneSignal , Geektime ",
44 | "license": "MIT"
45 | }
46 |
--------------------------------------------------------------------------------
/react-native-onesignal.podspec:
--------------------------------------------------------------------------------
1 | require 'json'
2 | package_json = JSON.parse(File.read('package.json'))
3 |
4 | Pod::Spec.new do |s|
5 | s.name = "react-native-onesignal"
6 | s.version = package_json["version"]
7 | s.summary = package_json["description"]
8 | s.homepage = "https://github.com/OneSignal/react-native-onesignal"
9 | s.license = package_json["license"]
10 | s.author = { package_json["author"] => package_json["author"] }
11 | s.platform = :ios, "11.0"
12 | s.source = { :git => "#{package_json["repository"]["url"]}.git", :tag => "#{s.version}" }
13 | s.source_files = 'ios/RCTOneSignal/*.{h,m}'
14 | s.static_framework = true
15 | # The "React" pod is required due to the use of RCTBridgeModule, RCTEventEmitter, etc
16 | # Ensuring we have version 0.13.0 or greater to avoid a cocoapods issue noted in React Native's release notes
17 | # https://github.com/facebook/react-native/releases/tag/v0.13.0
18 | # The last stable version on Cocapod's repo is 0.11.0 as we want to ignore it to always use the local copy.
19 | s.dependency 'React', '>= 0.13.0', '< 1.0.0'
20 |
21 | # REQUIRED: Ensure you have the following in your project's Podfile
22 | # pod 'React', :path => '../node_modules/react-native/'
23 |
24 | # The Native OneSignal-iOS-SDK XCFramework from cocoapods.
25 | s.dependency 'OneSignalXCFramework', '5.2.13'
26 | end
27 |
--------------------------------------------------------------------------------
/src/OSNotification.ts:
--------------------------------------------------------------------------------
1 | import { NativeModules, Platform } from 'react-native';
2 | const RNOneSignal = NativeModules.OneSignal;
3 |
4 | export default class OSNotification {
5 | body: string;
6 | sound?: string;
7 | title?: string;
8 | launchURL?: string;
9 | rawPayload: object | string; // platform bridges return different types
10 | actionButtons?: object[];
11 | additionalData?: object;
12 | notificationId: string;
13 | // android only
14 | groupKey?: string;
15 | groupMessage?: string;
16 | ledColor?: string;
17 | priority?: number;
18 | smallIcon?: string;
19 | largeIcon?: string;
20 | bigPicture?: string;
21 | collapseId?: string;
22 | fromProjectNumber?: string;
23 | smallIconAccentColor?: string;
24 | lockScreenVisibility?: string;
25 | androidNotificationId?: number;
26 | // ios only
27 | badge?: string;
28 | badgeIncrement?: string;
29 | category?: string;
30 | threadId?: string;
31 | subtitle?: string;
32 | templateId?: string;
33 | templateName?: string;
34 | attachments?: object;
35 | mutableContent?: boolean;
36 | contentAvailable?: string;
37 | relevanceScore?: number;
38 | interruptionLevel?: string;
39 |
40 | constructor(receivedEvent: OSNotification) {
41 | this.body = receivedEvent.body;
42 | this.sound = receivedEvent.sound;
43 | this.title = receivedEvent.title;
44 | this.launchURL = receivedEvent.launchURL;
45 | this.rawPayload = receivedEvent.rawPayload;
46 | this.actionButtons = receivedEvent.actionButtons;
47 | this.additionalData = receivedEvent.additionalData;
48 | this.notificationId = receivedEvent.notificationId;
49 |
50 | if (Platform.OS === 'android') {
51 | this.groupKey = receivedEvent.groupKey;
52 | this.ledColor = receivedEvent.ledColor;
53 | this.priority = receivedEvent.priority;
54 | this.smallIcon = receivedEvent.smallIcon;
55 | this.largeIcon = receivedEvent.largeIcon;
56 | this.bigPicture = receivedEvent.bigPicture;
57 | this.collapseId = receivedEvent.collapseId;
58 | this.groupMessage = receivedEvent.groupMessage;
59 | this.fromProjectNumber = receivedEvent.fromProjectNumber;
60 | this.smallIconAccentColor = receivedEvent.smallIconAccentColor;
61 | this.lockScreenVisibility = receivedEvent.lockScreenVisibility;
62 | this.androidNotificationId = receivedEvent.androidNotificationId;
63 | }
64 |
65 | if (Platform.OS === 'ios') {
66 | this.badge = receivedEvent.badge;
67 | this.category = receivedEvent.category;
68 | this.threadId = receivedEvent.threadId;
69 | this.subtitle = receivedEvent.subtitle;
70 | this.templateId = receivedEvent.templateId;
71 | this.attachments = receivedEvent.attachments;
72 | this.templateName = receivedEvent.templateName;
73 | this.mutableContent = receivedEvent.mutableContent;
74 | this.badgeIncrement = receivedEvent.badgeIncrement;
75 | this.contentAvailable = receivedEvent.contentAvailable;
76 | this.relevanceScore = receivedEvent.relevanceScore;
77 | this.interruptionLevel = receivedEvent.interruptionLevel;
78 | }
79 | }
80 |
81 | display(): void {
82 | RNOneSignal.displayNotification(this.notificationId);
83 | return;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/events/EventManager.ts:
--------------------------------------------------------------------------------
1 | import {
2 | EmitterSubscription,
3 | NativeEventEmitter,
4 | NativeModule,
5 | } from 'react-native';
6 | import NotificationWillDisplayEvent from './NotificationWillDisplayEvent';
7 | import {
8 | PERMISSION_CHANGED,
9 | SUBSCRIPTION_CHANGED,
10 | USER_STATE_CHANGED,
11 | NOTIFICATION_WILL_DISPLAY,
12 | NOTIFICATION_CLICKED,
13 | IN_APP_MESSAGE_CLICKED,
14 | IN_APP_MESSAGE_WILL_DISPLAY,
15 | IN_APP_MESSAGE_WILL_DISMISS,
16 | IN_APP_MESSAGE_DID_DISMISS,
17 | IN_APP_MESSAGE_DID_DISPLAY,
18 | } from './events';
19 | import OSNotification from '../OSNotification';
20 |
21 | const eventList = [
22 | PERMISSION_CHANGED,
23 | SUBSCRIPTION_CHANGED,
24 | USER_STATE_CHANGED,
25 | NOTIFICATION_WILL_DISPLAY,
26 | NOTIFICATION_CLICKED,
27 | IN_APP_MESSAGE_CLICKED,
28 | IN_APP_MESSAGE_WILL_DISPLAY,
29 | IN_APP_MESSAGE_WILL_DISMISS,
30 | IN_APP_MESSAGE_DID_DISMISS,
31 | IN_APP_MESSAGE_DID_DISPLAY,
32 | ];
33 |
34 | export default class EventManager {
35 | private RNOneSignal: NativeModule;
36 | private oneSignalEventEmitter: NativeEventEmitter;
37 | private eventListenerArrayMap: Map void>>;
38 | private listeners: { [key: string]: EmitterSubscription };
39 |
40 | constructor(RNOneSignal: NativeModule) {
41 | this.RNOneSignal = RNOneSignal;
42 | this.oneSignalEventEmitter = new NativeEventEmitter(RNOneSignal);
43 | this.eventListenerArrayMap = new Map(); // used for adders (multiple callbacks possible)
44 | this.listeners = {};
45 | this.setupListeners();
46 | }
47 |
48 | setupListeners() {
49 | // set up the event emitter and listeners
50 | if (this.RNOneSignal != null) {
51 | for (let i = 0; i < eventList.length; i++) {
52 | let eventName = eventList[i];
53 | this.listeners[eventName] = this.generateEventListener(eventName);
54 | }
55 | }
56 | }
57 |
58 | /**
59 | * Adds the event handler to the corresponding handler array on the JS side of the bridge
60 | * @param {string} eventName
61 | * @param {function} handler
62 | * @returns void
63 | */
64 | addEventListener(eventName: string, handler: (event: T) => void) {
65 | let handlerArray = this.eventListenerArrayMap.get(eventName);
66 | handlerArray && handlerArray.length > 0
67 | ? handlerArray.push(handler)
68 | : this.eventListenerArrayMap.set(eventName, [handler]);
69 | }
70 |
71 | /**
72 | * clears the event handler(s) for the event name
73 | * @param {string} eventName
74 | * @param {function} handler
75 | * @returns void
76 | */
77 | removeEventListener(eventName: string, handler: any) {
78 | const handlerArray = this.eventListenerArrayMap.get(eventName);
79 | if (!handlerArray) {
80 | return;
81 | }
82 | const index = handlerArray.indexOf(handler);
83 | if (index !== -1) {
84 | handlerArray.splice(index, 1);
85 | }
86 | if (handlerArray.length === 0) {
87 | this.eventListenerArrayMap.delete(eventName);
88 | }
89 | }
90 |
91 | // returns an event listener with the js to native mapping
92 | generateEventListener(eventName: string): EmitterSubscription {
93 | const addListenerCallback = (payload: Object) => {
94 | let handlerArray = this.eventListenerArrayMap.get(eventName);
95 | if (handlerArray) {
96 | if (eventName === NOTIFICATION_WILL_DISPLAY) {
97 | handlerArray.forEach((handler) => {
98 | handler(
99 | new NotificationWillDisplayEvent(payload as OSNotification),
100 | );
101 | });
102 | } else if (eventName === PERMISSION_CHANGED) {
103 | const typedPayload = payload as { permission: boolean };
104 | handlerArray.forEach((handler) => {
105 | handler(typedPayload.permission);
106 | });
107 | } else {
108 | handlerArray.forEach((handler) => {
109 | handler(payload);
110 | });
111 | }
112 | }
113 | };
114 |
115 | return this.oneSignalEventEmitter.addListener(
116 | eventName,
117 | addListenerCallback,
118 | );
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/src/events/NotificationWillDisplayEvent.ts:
--------------------------------------------------------------------------------
1 | import { NativeModules } from 'react-native';
2 | import OSNotification from '../OSNotification';
3 | const RNOneSignal = NativeModules.OneSignal;
4 |
5 | export default class NotificationWillDisplayEvent {
6 | public notification: OSNotification;
7 |
8 | constructor(displayEvent: OSNotification) {
9 | this.notification = new OSNotification(displayEvent);
10 | }
11 |
12 | preventDefault(): void {
13 | RNOneSignal.preventDefault(this.notification.notificationId);
14 | return;
15 | }
16 |
17 | getNotification(): OSNotification {
18 | return this.notification;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/events/events.ts:
--------------------------------------------------------------------------------
1 | export const NOTIFICATION_WILL_DISPLAY =
2 | 'OneSignal-notificationWillDisplayInForeground';
3 | export const NOTIFICATION_CLICKED = 'OneSignal-notificationClicked';
4 | export const IN_APP_MESSAGE_CLICKED = 'OneSignal-inAppMessageClicked';
5 | export const IN_APP_MESSAGE_WILL_DISPLAY = 'OneSignal-inAppMessageWillDisplay';
6 | export const IN_APP_MESSAGE_DID_DISPLAY = 'OneSignal-inAppMessageDidDisplay';
7 | export const IN_APP_MESSAGE_WILL_DISMISS = 'OneSignal-inAppMessageWillDismiss';
8 | export const IN_APP_MESSAGE_DID_DISMISS = 'OneSignal-inAppMessageDidDismiss';
9 | export const PERMISSION_CHANGED = 'OneSignal-permissionChanged';
10 | export const SUBSCRIPTION_CHANGED = 'OneSignal-subscriptionChanged';
11 | export const USER_STATE_CHANGED = 'OneSignal-userStateChanged';
12 |
--------------------------------------------------------------------------------
/src/helpers.ts:
--------------------------------------------------------------------------------
1 | import invariant from 'invariant';
2 | import { NativeModule } from 'react-native';
3 |
4 | export function isValidCallback(handler: Function) {
5 | invariant(typeof handler === 'function', 'Must provide a valid callback');
6 | }
7 |
8 | export function isNativeModuleLoaded(module: NativeModule): boolean {
9 | if (module == null) {
10 | console.error(
11 | 'Could not load RNOneSignal native module. Make sure native dependencies are properly linked.',
12 | );
13 |
14 | return false;
15 | }
16 |
17 | return true;
18 | }
19 |
--------------------------------------------------------------------------------
/src/models/InAppMessage.ts:
--------------------------------------------------------------------------------
1 | export type InAppMessageEventName =
2 | | 'click'
3 | | 'willDisplay'
4 | | 'didDisplay'
5 | | 'willDismiss'
6 | | 'didDismiss';
7 |
8 | export type InAppMessageEventTypeMap = {
9 | click: InAppMessageClickEvent;
10 | willDisplay: InAppMessageWillDisplayEvent;
11 | didDisplay: InAppMessageDidDisplayEvent;
12 | willDismiss: InAppMessageWillDismissEvent;
13 | didDismiss: InAppMessageDidDismissEvent;
14 | };
15 |
16 | export interface InAppMessage {
17 | messageId: string;
18 | }
19 |
20 | export interface InAppMessageClickEvent {
21 | message: InAppMessage;
22 | result: InAppMessageClickResult;
23 | }
24 |
25 | export interface InAppMessageClickResult {
26 | closingMessage: boolean;
27 | actionId?: string;
28 | url?: string;
29 | urlTarget?: string;
30 | }
31 |
32 | export interface InAppMessageWillDisplayEvent {
33 | message: InAppMessage;
34 | }
35 |
36 | export interface InAppMessageDidDisplayEvent {
37 | message: InAppMessage;
38 | }
39 |
40 | export interface InAppMessageWillDismissEvent {
41 | message: InAppMessage;
42 | }
43 |
44 | export interface InAppMessageDidDismissEvent {
45 | message: InAppMessage;
46 | }
47 |
--------------------------------------------------------------------------------
/src/models/LiveActivities.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * The setup options for `OneSignal.LiveActivities.setupDefault`.
3 | */
4 | export type LiveActivitySetupOptions = {
5 | /**
6 | * When true, OneSignal will listen for pushToStart tokens for the `OneSignalLiveActivityAttributes` structure.
7 | */
8 | enablePushToStart: boolean;
9 |
10 | /**
11 | * When true, OneSignal will listen for pushToUpdate tokens for each start live activity that uses the
12 | * `OneSignalLiveActivityAttributes` structure.
13 | */
14 | enablePushToUpdate: boolean;
15 | };
16 |
--------------------------------------------------------------------------------
/src/models/NotificationEvents.ts:
--------------------------------------------------------------------------------
1 | import OSNotification from '../OSNotification';
2 | import NotificationWillDisplayEvent from '../events/NotificationWillDisplayEvent';
3 |
4 | export type NotificationEventName =
5 | | 'click'
6 | | 'foregroundWillDisplay'
7 | | 'permissionChange';
8 |
9 | export type NotificationEventTypeMap = {
10 | click: NotificationClickEvent;
11 | foregroundWillDisplay: NotificationWillDisplayEvent;
12 | permissionChange: boolean;
13 | };
14 |
15 | export interface NotificationClickEvent {
16 | result: NotificationClickResult;
17 | notification: OSNotification;
18 | }
19 |
20 | export interface NotificationClickResult {
21 | actionId?: string;
22 | url?: string;
23 | }
24 |
--------------------------------------------------------------------------------
/src/models/Subscription.ts:
--------------------------------------------------------------------------------
1 | export enum OSNotificationPermission {
2 | NotDetermined = 0,
3 | Denied,
4 | Authorized,
5 | Provisional, // only available in iOS 12
6 | Ephemeral, // only available in iOS 14
7 | }
8 |
9 | export interface PushSubscriptionState {
10 | id?: string;
11 | token?: string;
12 | optedIn: boolean;
13 | }
14 |
15 | export interface PushSubscriptionChangedState {
16 | previous: PushSubscriptionState;
17 | current: PushSubscriptionState;
18 | }
19 |
--------------------------------------------------------------------------------
/src/models/User.ts:
--------------------------------------------------------------------------------
1 | export interface UserState {
2 | externalId?: string;
3 | onesignalId?: string;
4 | }
5 |
6 | export interface UserChangedState {
7 | current: UserState;
8 | }
9 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "outDir": "dist",
4 | "target": "es5",
5 | "moduleResolution": "node",
6 | "noImplicitAny": true,
7 | "lib": ["es6"],
8 | "rootDir": "src",
9 | "declaration": true,
10 | "allowSyntheticDefaultImports": true,
11 | "skipLibCheck": true,
12 | "esModuleInterop": true,
13 | "strict": true,
14 | "noUnusedLocals": true
15 | },
16 | "exclude": ["node_modules", "dist", "android", "examples", "ios"]
17 | }
18 |
--------------------------------------------------------------------------------