pushwoosh-react-native-plugin 6.1.35 → 6.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.yml +1 -0
- package/example/LICENSE +21 -0
- package/example/README.md +58 -0
- package/example/Screenshots/Android_1.png +0 -0
- package/example/Screenshots/Android_2.png +0 -0
- package/example/Screenshots/iOS_1.png +0 -0
- package/example/Screenshots/iOS_2.png +0 -0
- package/example/demoapp/.bundle/config +2 -0
- package/example/demoapp/.eslintrc.js +4 -0
- package/example/demoapp/.prettierrc.js +7 -0
- package/example/demoapp/.watchmanconfig +1 -0
- package/example/demoapp/Actions.js +302 -0
- package/example/demoapp/App.tsx +118 -0
- package/example/demoapp/Gemfile +9 -0
- package/example/demoapp/Gemfile.lock +105 -0
- package/example/demoapp/README.md +79 -0
- package/example/demoapp/Settings.js +126 -0
- package/example/demoapp/__tests__/App.test.tsx +17 -0
- package/example/demoapp/android/app/build.gradle +118 -0
- package/example/demoapp/android/app/debug.keystore +0 -0
- package/example/demoapp/android/app/google-services.json +979 -0
- package/example/demoapp/android/app/proguard-rules.pro +10 -0
- package/example/demoapp/android/app/src/debug/AndroidManifest.xml +9 -0
- package/example/demoapp/android/app/src/main/AndroidManifest.xml +25 -0
- package/example/demoapp/android/app/src/main/java/com/demoapp/MainActivity.kt +22 -0
- package/example/demoapp/android/app/src/main/java/com/demoapp/MainApplication.kt +43 -0
- package/example/demoapp/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/example/demoapp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/example/demoapp/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/example/demoapp/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/example/demoapp/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/example/demoapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/example/demoapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/example/demoapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/example/demoapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/example/demoapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/example/demoapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/example/demoapp/android/app/src/main/res/values/strings.xml +3 -0
- package/example/demoapp/android/app/src/main/res/values/styles.xml +9 -0
- package/example/demoapp/android/build.gradle +21 -0
- package/example/demoapp/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/demoapp/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/example/demoapp/android/gradle.properties +41 -0
- package/example/demoapp/android/gradlew +249 -0
- package/example/demoapp/android/gradlew.bat +92 -0
- package/example/demoapp/android/settings.gradle +4 -0
- package/example/demoapp/app.json +4 -0
- package/example/demoapp/babel.config.js +3 -0
- package/example/demoapp/index.js +46 -0
- package/example/demoapp/ios/.xcode.env +11 -0
- package/example/demoapp/ios/NotificationService/Info.plist +15 -0
- package/example/demoapp/ios/NotificationService/NotificationService.entitlements +8 -0
- package/example/demoapp/ios/NotificationService/NotificationService.swift +38 -0
- package/example/demoapp/ios/Podfile +40 -0
- package/example/demoapp/ios/demoapp/AppDelegate.h +6 -0
- package/example/demoapp/ios/demoapp/AppDelegate.mm +31 -0
- package/example/demoapp/ios/demoapp/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/example/demoapp/ios/demoapp/Images.xcassets/Contents.json +6 -0
- package/example/demoapp/ios/demoapp/Info.plist +57 -0
- package/example/demoapp/ios/demoapp/LaunchScreen.storyboard +47 -0
- package/example/demoapp/ios/demoapp/PrivacyInfo.xcprivacy +37 -0
- package/example/demoapp/ios/demoapp/demoapp.entitlements +10 -0
- package/example/demoapp/ios/demoapp/main.m +10 -0
- package/example/demoapp/ios/demoapp.xcodeproj/project.pbxproj +937 -0
- package/example/demoapp/ios/demoapp.xcodeproj/xcshareddata/xcschemes/demoapp.xcscheme +88 -0
- package/example/demoapp/ios/demoapp.xcworkspace/contents.xcworkspacedata +10 -0
- package/example/demoapp/ios/demoapp.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/example/demoapp/ios/demoappTests/Info.plist +24 -0
- package/example/demoapp/ios/demoappTests/demoappTests.m +66 -0
- package/example/demoapp/jest.config.js +3 -0
- package/example/demoapp/logos.png +0 -0
- package/example/demoapp/metro.config.js +20 -0
- package/example/demoapp/package.json +42 -0
- package/example/demoapp/tsconfig.json +3 -0
- package/example/demoapp/yarn.lock +7153 -0
- package/package.json +1 -1
- package/pushwoosh-react-native-plugin.podspec +1 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
|
|
2
|
+
|
|
3
|
+
# Getting Started
|
|
4
|
+
|
|
5
|
+
>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
|
|
6
|
+
|
|
7
|
+
## Step 1: Start the Metro Server
|
|
8
|
+
|
|
9
|
+
First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.
|
|
10
|
+
|
|
11
|
+
To start Metro, run the following command from the _root_ of your React Native project:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# using npm
|
|
15
|
+
npm start
|
|
16
|
+
|
|
17
|
+
# OR using Yarn
|
|
18
|
+
yarn start
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Step 2: Start your Application
|
|
22
|
+
|
|
23
|
+
Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:
|
|
24
|
+
|
|
25
|
+
### For Android
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# using npm
|
|
29
|
+
npm run android
|
|
30
|
+
|
|
31
|
+
# OR using Yarn
|
|
32
|
+
yarn android
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### For iOS
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# using npm
|
|
39
|
+
npm run ios
|
|
40
|
+
|
|
41
|
+
# OR using Yarn
|
|
42
|
+
yarn ios
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.
|
|
46
|
+
|
|
47
|
+
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
|
|
48
|
+
|
|
49
|
+
## Step 3: Modifying your App
|
|
50
|
+
|
|
51
|
+
Now that you have successfully run the app, let's modify it.
|
|
52
|
+
|
|
53
|
+
1. Open `App.tsx` in your text editor of choice and edit some lines.
|
|
54
|
+
2. For **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Developer Menu** (<kbd>Ctrl</kbd> + <kbd>M</kbd> (on Window and Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (on macOS)) to see your changes!
|
|
55
|
+
|
|
56
|
+
For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes!
|
|
57
|
+
|
|
58
|
+
## Congratulations! :tada:
|
|
59
|
+
|
|
60
|
+
You've successfully run and modified your React Native App. :partying_face:
|
|
61
|
+
|
|
62
|
+
### Now what?
|
|
63
|
+
|
|
64
|
+
- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
|
|
65
|
+
- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).
|
|
66
|
+
|
|
67
|
+
# Troubleshooting
|
|
68
|
+
|
|
69
|
+
If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
|
|
70
|
+
|
|
71
|
+
# Learn More
|
|
72
|
+
|
|
73
|
+
To learn more about React Native, take a look at the following resources:
|
|
74
|
+
|
|
75
|
+
- [React Native Website](https://reactnative.dev) - learn more about React Native.
|
|
76
|
+
- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
|
|
77
|
+
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
|
|
78
|
+
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
|
|
79
|
+
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { View, Text, StyleSheet, Switch } from 'react-native';
|
|
3
|
+
import Pushwoosh from 'pushwoosh-react-native-plugin';
|
|
4
|
+
|
|
5
|
+
const Settings = () => {
|
|
6
|
+
const [isEnabledRegister, setIsEnabledRegister] = useState(false);
|
|
7
|
+
const [isEnabledServer, setIsEnabledServer] = useState(true);
|
|
8
|
+
|
|
9
|
+
const toggleSwitchNotification = () => {
|
|
10
|
+
setIsEnabledRegister(previousState => !previousState);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (isEnabledRegister) {
|
|
15
|
+
/**
|
|
16
|
+
* initialize Pushwoosh SDK.
|
|
17
|
+
* Example params: {"pw_appid": "application id", "project_number": "FCM sender id"}
|
|
18
|
+
*
|
|
19
|
+
* 1. app_id - YOUR_APP_ID
|
|
20
|
+
* 2. sender_id - FCM_SENDER_ID
|
|
21
|
+
*/
|
|
22
|
+
Pushwoosh.init({ "pw_appid" : "XXXXX-XXXXX", "project_number":"XXXXXXXXXXXX"});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* To register for push notifications, call the following method:
|
|
26
|
+
*
|
|
27
|
+
* PUSHWOOSH CODE
|
|
28
|
+
* | |
|
|
29
|
+
* _| |_
|
|
30
|
+
* \ /
|
|
31
|
+
* \ /
|
|
32
|
+
* \_/
|
|
33
|
+
*/
|
|
34
|
+
Pushwoosh.register(
|
|
35
|
+
(token) => {
|
|
36
|
+
console.warn("Registered for pushes: " + token);
|
|
37
|
+
Pushwoosh.getPushToken(function(token) {
|
|
38
|
+
console.warn("Push token: " + token);
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
(error) => {
|
|
42
|
+
console.warn("Failed to register: " + error);
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
} else {
|
|
46
|
+
/**
|
|
47
|
+
* To unregister for push notifications, call the following method:
|
|
48
|
+
*
|
|
49
|
+
* PUSHWOOSH CODE
|
|
50
|
+
* | |
|
|
51
|
+
* _| |_
|
|
52
|
+
* \ /
|
|
53
|
+
* \ /
|
|
54
|
+
* \_/
|
|
55
|
+
*/
|
|
56
|
+
Pushwoosh.unregister();
|
|
57
|
+
}
|
|
58
|
+
}, [isEnabledRegister]);
|
|
59
|
+
|
|
60
|
+
const toggleSwitchServerCommunication = () => {
|
|
61
|
+
setIsEnabledServer(previousState => !previousState);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (isEnabledServer) {
|
|
66
|
+
/**
|
|
67
|
+
* Server Communication Enable = true
|
|
68
|
+
*/
|
|
69
|
+
Pushwoosh.setCommunicationEnabled(true);
|
|
70
|
+
} else {
|
|
71
|
+
/**
|
|
72
|
+
* Server Communication Enable = false
|
|
73
|
+
*/
|
|
74
|
+
Pushwoosh.setCommunicationEnabled(false);
|
|
75
|
+
}
|
|
76
|
+
}, [isEnabledServer]);
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<View style={styles.container}>
|
|
80
|
+
<View style={styles.row}>
|
|
81
|
+
<Text style={styles.label}>Register For Push Notifications</Text>
|
|
82
|
+
<Switch
|
|
83
|
+
trackColor={{ false: "#767577", true: "#81b0ff" }}
|
|
84
|
+
thumbColor={isEnabledRegister ? "#f5dd4b" : "#f4f3f4"}
|
|
85
|
+
ios_backgroundColor="#3e3e3e"
|
|
86
|
+
onValueChange={toggleSwitchNotification}
|
|
87
|
+
value={isEnabledRegister}
|
|
88
|
+
/>
|
|
89
|
+
</View>
|
|
90
|
+
<View style={styles.container}>
|
|
91
|
+
<View style={styles.row}>
|
|
92
|
+
<Text style={styles.label}>Server Communication Enabled</Text>
|
|
93
|
+
<Switch
|
|
94
|
+
trackColor={{ false: "#767577", true: "#81b0ff" }}
|
|
95
|
+
thumbColor={isEnabledServer ? "#f5dd4b" : "#f4f3f4"}
|
|
96
|
+
ios_backgroundColor="#3e3e3e"
|
|
97
|
+
onValueChange={toggleSwitchServerCommunication}
|
|
98
|
+
value={isEnabledServer}
|
|
99
|
+
/>
|
|
100
|
+
</View>
|
|
101
|
+
</View>
|
|
102
|
+
</View>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const styles = StyleSheet.create({
|
|
107
|
+
container: {
|
|
108
|
+
flex: 1,
|
|
109
|
+
justifyContent: 'flex-start',
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
backgroundColor: '#ffffff',
|
|
112
|
+
paddingTop: 20,
|
|
113
|
+
},
|
|
114
|
+
row: {
|
|
115
|
+
flexDirection: 'row',
|
|
116
|
+
alignItems: 'center',
|
|
117
|
+
justifyContent: 'space-between',
|
|
118
|
+
paddingHorizontal: 20,
|
|
119
|
+
width: '100%',
|
|
120
|
+
},
|
|
121
|
+
label: {
|
|
122
|
+
fontSize: 18,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
export default Settings;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @format
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import 'react-native';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import App from '../App';
|
|
8
|
+
|
|
9
|
+
// Note: import explicitly to use the types shipped with jest.
|
|
10
|
+
import {it} from '@jest/globals';
|
|
11
|
+
|
|
12
|
+
// Note: test renderer must be required after react-native.
|
|
13
|
+
import renderer from 'react-test-renderer';
|
|
14
|
+
|
|
15
|
+
it('renders correctly', () => {
|
|
16
|
+
renderer.create(<App />);
|
|
17
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
apply plugin: "com.android.application"
|
|
2
|
+
apply plugin: "org.jetbrains.kotlin.android"
|
|
3
|
+
apply plugin: "com.facebook.react"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This is the configuration block to customize your React Native Android app.
|
|
7
|
+
* By default you don't need to apply any configuration, just uncomment the lines you need.
|
|
8
|
+
*/
|
|
9
|
+
react {
|
|
10
|
+
/* Folders */
|
|
11
|
+
// The root of your project, i.e. where "package.json" lives. Default is '..'
|
|
12
|
+
// root = file("../")
|
|
13
|
+
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
|
|
14
|
+
// reactNativeDir = file("../node_modules/react-native")
|
|
15
|
+
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
|
|
16
|
+
// codegenDir = file("../node_modules/@react-native/codegen")
|
|
17
|
+
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
|
|
18
|
+
// cliFile = file("../node_modules/react-native/cli.js")
|
|
19
|
+
|
|
20
|
+
/* Variants */
|
|
21
|
+
// The list of variants to that are debuggable. For those we're going to
|
|
22
|
+
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
|
|
23
|
+
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
|
|
24
|
+
// debuggableVariants = ["liteDebug", "prodDebug"]
|
|
25
|
+
|
|
26
|
+
/* Bundling */
|
|
27
|
+
// A list containing the node command and its flags. Default is just 'node'.
|
|
28
|
+
// nodeExecutableAndArgs = ["node"]
|
|
29
|
+
//
|
|
30
|
+
// The command to run when bundling. By default is 'bundle'
|
|
31
|
+
// bundleCommand = "ram-bundle"
|
|
32
|
+
//
|
|
33
|
+
// The path to the CLI configuration file. Default is empty.
|
|
34
|
+
// bundleConfig = file(../rn-cli.config.js)
|
|
35
|
+
//
|
|
36
|
+
// The name of the generated asset file containing your JS bundle
|
|
37
|
+
// bundleAssetName = "MyApplication.android.bundle"
|
|
38
|
+
//
|
|
39
|
+
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
|
|
40
|
+
// entryFile = file("../js/MyApplication.android.js")
|
|
41
|
+
//
|
|
42
|
+
// A list of extra flags to pass to the 'bundle' commands.
|
|
43
|
+
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
|
|
44
|
+
// extraPackagerArgs = []
|
|
45
|
+
|
|
46
|
+
/* Hermes Commands */
|
|
47
|
+
// The hermes compiler command to run. By default it is 'hermesc'
|
|
48
|
+
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
|
|
49
|
+
//
|
|
50
|
+
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
|
|
51
|
+
// hermesFlags = ["-O", "-output-source-map"]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
|
|
56
|
+
*/
|
|
57
|
+
def enableProguardInReleaseBuilds = false
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The preferred build flavor of JavaScriptCore (JSC)
|
|
61
|
+
*
|
|
62
|
+
* For example, to use the international variant, you can use:
|
|
63
|
+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
|
|
64
|
+
*
|
|
65
|
+
* The international variant includes ICU i18n library and necessary data
|
|
66
|
+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
|
|
67
|
+
* give correct results when using with locales other than en-US. Note that
|
|
68
|
+
* this variant is about 6MiB larger per architecture than default.
|
|
69
|
+
*/
|
|
70
|
+
def jscFlavor = 'org.webkit:android-jsc:+'
|
|
71
|
+
|
|
72
|
+
android {
|
|
73
|
+
ndkVersion rootProject.ext.ndkVersion
|
|
74
|
+
buildToolsVersion rootProject.ext.buildToolsVersion
|
|
75
|
+
compileSdk rootProject.ext.compileSdkVersion
|
|
76
|
+
|
|
77
|
+
namespace "com.demoapp"
|
|
78
|
+
defaultConfig {
|
|
79
|
+
applicationId "com.demoapp"
|
|
80
|
+
minSdkVersion rootProject.ext.minSdkVersion
|
|
81
|
+
targetSdkVersion rootProject.ext.targetSdkVersion
|
|
82
|
+
versionCode 1
|
|
83
|
+
versionName "1.0"
|
|
84
|
+
}
|
|
85
|
+
signingConfigs {
|
|
86
|
+
debug {
|
|
87
|
+
storeFile file('debug.keystore')
|
|
88
|
+
storePassword 'android'
|
|
89
|
+
keyAlias 'androiddebugkey'
|
|
90
|
+
keyPassword 'android'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
buildTypes {
|
|
94
|
+
debug {
|
|
95
|
+
signingConfig signingConfigs.debug
|
|
96
|
+
}
|
|
97
|
+
release {
|
|
98
|
+
// Caution! In production, you need to generate your own keystore file.
|
|
99
|
+
// see https://reactnative.dev/docs/signed-apk-android.
|
|
100
|
+
signingConfig signingConfigs.debug
|
|
101
|
+
minifyEnabled enableProguardInReleaseBuilds
|
|
102
|
+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
dependencies {
|
|
108
|
+
// The version of react-native is set by the React Native Gradle Plugin
|
|
109
|
+
implementation("com.facebook.react:react-android")
|
|
110
|
+
|
|
111
|
+
if (hermesEnabled.toBoolean()) {
|
|
112
|
+
implementation("com.facebook.react:hermes-android")
|
|
113
|
+
} else {
|
|
114
|
+
implementation jscFlavor
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
|
|
Binary file
|