├── .eslintrc.js ├── .github ├── ISSUE_TEMPLATE │ ├── ask-question.yml │ ├── bug-report.yml │ └── general-feedback.yml ├── os_probot_metadata.js ├── pull_request_template.md ├── release-drafter.yml ├── set_response_times.js └── workflows │ ├── Zapier.yml │ ├── ci.yml │ ├── codeql.yml │ ├── npm_deploy.yml │ ├── project.yml │ ├── release-drafter.yml │ └── set_response_time.yml ├── .gitignore ├── .npmignore ├── .prettierrc.js ├── CONTRIBUTING.md ├── LICENSE ├── MIGRATION_GUIDE.md ├── README.md ├── android ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── onesignal │ │ └── rnonesignalandroid │ │ ├── RNOneSignal.java │ │ ├── RNUtils.java │ │ └── ReactNativeOneSignalPackage.java │ └── res │ └── values │ └── strings.xml ├── babel.config.js ├── examples └── RNOneSignalTS │ ├── .buckconfig │ ├── .eslintrc.js │ ├── .gitattributes │ ├── .gitignore │ ├── .prettierrc.js │ ├── .watchmanconfig │ ├── __tests__ │ └── App-test.tsx │ ├── android │ ├── app │ │ ├── _BUCK │ │ ├── build.gradle │ │ ├── build_defs.bzl │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── rnonesignalts │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── rnonesignalts │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle │ ├── app.json │ ├── babel.config.js │ ├── index.js │ ├── ios │ ├── OneSignalNotificationServiceExtension │ │ ├── Info.plist │ │ ├── NotificationService.h │ │ └── NotificationService.m │ ├── Podfile │ ├── Podfile.lock │ ├── RNOneSignalTS-tvOS │ │ └── Info.plist │ ├── RNOneSignalTS-tvOSTests │ │ └── Info.plist │ ├── RNOneSignalTS.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── RNOneSignalTS-tvOS.xcscheme │ │ │ └── RNOneSignalTS.xcscheme │ ├── RNOneSignalTS.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── RNOneSignalTS │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ ├── RNOneSignalTS.entitlements │ │ └── main.m │ ├── RNOneSignalTSTests │ │ ├── Info.plist │ │ └── RNOneSignalTSTests.m │ ├── RNOneSignalWidget │ │ ├── Assets.xcassets │ │ │ ├── AccentColor.colorset │ │ │ │ └── Contents.json │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ ├── Contents.json │ │ │ ├── WidgetBackground.colorset │ │ │ │ └── Contents.json │ │ │ └── onesignaldemo.imageset │ │ │ │ ├── Contents.json │ │ │ │ └── onesignal-logo.png │ │ ├── Info.plist │ │ ├── RNOneSignalWidgetBundle.swift │ │ └── RNOneSignalWidgetLiveActivity.swift │ └── RNOneSignalWidgetExtension.entitlements │ ├── metro.config.js │ ├── package.json │ ├── src │ ├── App.tsx │ ├── Helpers.tsx │ ├── OSButtons.tsx │ ├── OSConsole.tsx │ └── OSDemo.tsx │ ├── tsconfig.json │ └── update_example ├── images ├── 1abfb4e-Xcode_create_notification_service_extension_2.png ├── 5c47cf5-Xcode_create_notification_service_extension_3.png ├── 74a6d44-Xcode_create_notification_service_extension_1.png ├── build-settings-search-paths.png └── linked-libraries.png ├── ios ├── RCTOneSignal.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── RCTOneSignal │ ├── RCTOneSignal.h │ ├── RCTOneSignal.m │ ├── RCTOneSignalEventEmitter.h │ ├── RCTOneSignalEventEmitter.m │ ├── RCTOneSignalExtensionService.h │ ├── RCTOneSignalExtensionService.m │ └── UIApplication+RCTOnesignal.m ├── jest.config.js ├── metro.config.js ├── package.json ├── react-native-onesignal.podspec ├── src ├── OSNotification.ts ├── events │ ├── EventManager.ts │ ├── NotificationWillDisplayEvent.ts │ └── events.ts ├── helpers.ts ├── index.ts └── models │ ├── InAppMessage.ts │ ├── LiveActivities.ts │ ├── NotificationEvents.ts │ ├── Subscription.ts │ └── User.ts ├── tsconfig.json └── yarn.lock /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: ['@react-native-community', 'prettier'], 4 | parser: '@typescript-eslint/parser', 5 | plugins: ['@typescript-eslint'], 6 | }; 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/ask-question.yml: -------------------------------------------------------------------------------- 1 | name: 🙋‍♂️ Ask a question 2 | description: Tell us what's on your mind 3 | title: '[Question]: ' 4 | labels: ['Question'] 5 | 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | Having issues integrating this SDK? 11 | - type: textarea 12 | id: question 13 | attributes: 14 | label: How can we help? 15 | description: Specific question regarding integrating this SDK. 16 | placeholder: How do I...? 17 | validations: 18 | required: true 19 | - type: checkboxes 20 | id: terms 21 | attributes: 22 | label: Code of Conduct 23 | description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/OneSignal/react-native-onesignal/blob/main/CONTRIBUTING.md) 24 | options: 25 | - label: I agree to follow this project's Code of Conduct 26 | required: true 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.yml: -------------------------------------------------------------------------------- 1 | name: 🪳 Bug report 2 | description: File a bug report 3 | title: '[Bug]: ' 4 | labels: ['Bug'] 5 | 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | Thanks for taking the time to fill out this bug report! 11 | - type: textarea 12 | id: what-happened 13 | attributes: 14 | label: What happened? 15 | description: Provide a thorough description of whats going on. 16 | placeholder: e.g. The latest version of the SDK causes my screen to go blank when I tap on the screen three times. 17 | validations: 18 | required: true 19 | - type: textarea 20 | id: reproduction-steps 21 | attributes: 22 | label: Steps to reproduce? 23 | description: Provide as much detail as possible to reproduce the issue. 24 | placeholder: | 25 | 1. Install vX.Y.Z of dependency 26 | 2. Launch the app on iOS device 27 | 3. Tap the screen three times 28 | 4. Note that the app crashes 29 | render: Markdown 30 | validations: 31 | required: true 32 | - type: textarea 33 | id: what-are-expectations 34 | attributes: 35 | label: What did you expect to happen? 36 | description: Also tell us, what did you expect to happen? 37 | placeholder: I expected the app to continue running no matter how many times I tap the screen. 38 | validations: 39 | required: true 40 | - type: input 41 | id: react-native-onesignal-version 42 | attributes: 43 | label: React Native OneSignal SDK version 44 | description: What version of the React Native OneSignal SDK are you using? 45 | placeholder: Release 4.4.1 46 | validations: 47 | required: true 48 | - type: checkboxes 49 | id: platforms 50 | attributes: 51 | label: Which platform(s) are affected? 52 | description: Indicate which mobile platforms this issue is affecting 53 | options: 54 | - label: iOS 55 | required: false 56 | - label: Android 57 | required: false 58 | - type: textarea 59 | id: logs 60 | attributes: 61 | label: Relevant log output 62 | description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. 63 | render: Shell 64 | - type: checkboxes 65 | id: terms 66 | attributes: 67 | label: Code of Conduct 68 | description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/OneSignal/react-native-onesignal/blob/main/CONTRIBUTING.md) 69 | options: 70 | - label: I agree to follow this project's Code of Conduct 71 | required: true 72 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/general-feedback.yml: -------------------------------------------------------------------------------- 1 | name: 📣 General feedback 2 | description: Tell us what's on your mind 3 | title: '[Feedback]: ' 4 | labels: ['Feedback'] 5 | 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | Thanks for sharing your valuable feedback! 11 | - type: textarea 12 | id: feedback 13 | attributes: 14 | label: What's on your mind? 15 | description: Feedback regarding this SDK. 16 | placeholder: Share your feedback... 17 | validations: 18 | required: true 19 | - type: checkboxes 20 | id: terms 21 | attributes: 22 | label: Code of Conduct 23 | description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/OneSignal/react-native-onesignal/blob/main/CONTRIBUTING.md) 24 | options: 25 | - label: I agree to follow this project's Code of Conduct 26 | required: true 27 | -------------------------------------------------------------------------------- /.github/os_probot_metadata.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Based on probot-metadata - https://github.com/probot/metadata 3 | */ 4 | const regex = /\n\n/ 5 | 6 | const { Octokit } = require("@octokit/action") 7 | 8 | const octokit = new Octokit() 9 | 10 | module.exports = (context, issue = null) => { 11 | console.log(context) 12 | const prefix = "onesignal-probot" 13 | 14 | if (!issue) issue = context.payload.issue 15 | 16 | return { 17 | async get (key = null) { 18 | let body = issue.body 19 | 20 | if (!body) { 21 | body = (await octokit.issues.get(issue)).data.body || '' 22 | } 23 | 24 | const match = body.match(regex) 25 | 26 | if (match) { 27 | const data = JSON.parse(match[1])[prefix] 28 | return key ? data && data[key] : data 29 | } 30 | }, 31 | 32 | async set (key, value) { 33 | let body = issue.body 34 | let data = {} 35 | 36 | if (!body) body = (await octokit.issues.get(issue)).data.body || '' 37 | 38 | body = body.replace(regex, (_, json) => { 39 | data = JSON.parse(json) 40 | return '' 41 | }) 42 | 43 | if (!data[prefix]) data[prefix] = {} 44 | 45 | if (typeof key === 'object') { 46 | Object.assign(data[prefix], key) 47 | } else { 48 | data[prefix][key] = value 49 | } 50 | 51 | body = `${body}\n\n` 52 | 53 | const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/") 54 | const issue_number = context.payload.issue.number 55 | return octokit.issues.update({ owner, repo, issue_number, body }) 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # READ AND DELETE THIS SECTION BEFORE SUBMITTING PR 4 | 5 | - **Fill out each _REQUIRED_ section** 6 | - **Fill out _OPTIONAL_ sections, remove section if it doesn't apply to your PR** 7 | - **Read and fill out each of the checklists below** 8 | - **Remove this section after reading** 9 | 10 | 11 | # Description 12 | 13 | ## One Line Summary 14 | 15 | **REQUIRED** - Very short description that summaries the changes in this PR. 16 | 17 | ## Details 18 | 19 | ### Motivation 20 | 21 | **REQUIRED -** Why is this code change being made? Or what is the goal of this PR? Examples: Fixes a specific bug, provides additional logging to debug future issues, feature to allow X. 22 | 23 | ### Scope 24 | 25 | **RECOMMEND - OPTIONAL -** What is intended to be effected. What is known not to change. Example: Notifications are grouped when parameter X is set, not enabled by default. 26 | 27 | ### OPTIONAL - Other 28 | 29 | **OPTIONAL -** Feel free to add any other sections or sub-sections that can explain your PR better. 30 | 31 | # Testing 32 | 33 | ## Unit testing 34 | 35 | **OPTIONAL -** Explain unit tests added, if not clear in the code. 36 | 37 | ## Manual testing 38 | 39 | **RECOMMEND - OPTIONAL -** Explain what scenarios were tested and the environment. 40 | Example: Tested opening a notification while the app was foregrounded, app build with Android Studio 2020.3 with a fresh install of the OneSignal example app on a Pixel 6 with Android 12. 41 | 42 | # Affected code checklist 43 | 44 | - [ ] Notifications 45 | - [ ] Display 46 | - [ ] Open 47 | - [ ] Push Processing 48 | - [ ] Confirm Deliveries 49 | - [ ] Outcomes 50 | - [ ] Sessions 51 | - [ ] In-App Messaging 52 | - [ ] REST API requests 53 | - [ ] Public API changes 54 | 55 | # Checklist 56 | 57 | ## Overview 58 | 59 | - [ ] I have filled out all **REQUIRED** sections above 60 | - [ ] PR does one thing 61 | - If it is hard to explain how any codes changes are related to each other then it most likely needs to be more than one PR 62 | - [ ] Any Public API changes are explained in the PR details and conform to existing APIs 63 | 64 | ## Testing 65 | 66 | - [ ] I have included test coverage for these changes, or explained why they are not needed 67 | - [ ] All automated tests pass, or I explained why that is not possible 68 | - [ ] I have personally tested this on my device, or explained why that is not possible 69 | 70 | ## Final pass 71 | 72 | - [ ] Code is as readable as possible. 73 | - Simplify with less code, followed by splitting up code into well named functions and variables, followed by adding comments to the code. 74 | - [ ] I have reviewed this PR myself, ensuring it meets each checklist item 75 | - WIP (Work In Progress) is ok, but explain what is still in progress and what you would like feedback on. Start the PR title with "WIP" to indicate this. 76 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name-template: $RESOLVED_VERSION 2 | tag-template: $RESOLVED_VERSION 3 | categories: 4 | - title: 🚀 Features 5 | label: Enhancement / Feature 6 | - title: 🐛 Bug Fixes 7 | label: Bug 8 | - title: 🧰 Improvements 9 | label: Improvement 10 | - title: down arrow Dependency Updates 11 | label: Dependencies 12 | change-template: '- $TITLE (#$NUMBER)' 13 | version-resolver: 14 | major: 15 | labels: 16 | - 'major' 17 | minor: 18 | labels: 19 | - 'minor' 20 | patch: 21 | labels: 22 | - 'patch' 23 | default: patch 24 | template: | 25 | ## Other Changes 26 | 27 | $CHANGES 28 | -------------------------------------------------------------------------------- /.github/set_response_times.js: -------------------------------------------------------------------------------- 1 | function calcResponseTimeForIssueCreatedAt(createdAt) { 2 | const issueOpenedDate = new Date(createdAt); 3 | const issueTriagedDate = new Date(); 4 | const businessDaysResponseTime = calcBusinessDaysBetweenDates(issueOpenedDate, issueTriagedDate); 5 | return businessDaysResponseTime; 6 | } 7 | 8 | function calcBusinessDaysBetweenDates(openedDate, triagedDate) { 9 | let differenceInWeeks, responseTime; 10 | if (triagedDate < openedDate) 11 | return -1; // error code if dates transposed 12 | let openedDay = openedDate.getDay(); // day of week 13 | let triagedDay = triagedDate.getDay(); 14 | openedDay = (openedDay == 0) ? 7 : openedDay; // change Sunday from 0 to 7 15 | triagedDay = (triagedDay == 0) ? 7 : triagedDay; 16 | openedDay = (openedDay > 5) ? 5 : openedDay; // only count weekdays 17 | triagedDay = (triagedDay > 5) ? 5 : triagedDay; 18 | // calculate differnece in weeks (1000mS * 60sec * 60min * 24hrs * 7 days = 604800000) 19 | differenceInWeeks = Math.floor((triagedDate.getTime() - openedDate.getTime()) / 604800000); 20 | if (openedDay < triagedDay) { //Equal to makes it reduce 5 days 21 | responseTime = (differenceInWeeks * 5) + (triagedDay - openedDay); 22 | } 23 | else if (openedDay == triagedDay) { 24 | responseTime = differenceInWeeks * 5; 25 | } 26 | else { 27 | responseTime = ((differenceInWeeks + 1) * 5) - (openedDay - triagedDay); 28 | } 29 | return (responseTime); 30 | } 31 | 32 | module.exports = async(context, osmetadata) => { 33 | const foundResponseTime = await osmetadata(context).get('response_time_in_business_days'); 34 | if (foundResponseTime) { 35 | const foundString = "already found response time in business days: " + foundResponseTime 36 | console.log(foundString); 37 | return foundString; 38 | } 39 | if (context.payload.comment && context.payload.comment.author_association != "MEMBER" && context.payload.comment.author_association != "OWNER" && context.payload.comment.author_association != "CONTRIBUTOR") { 40 | return; 41 | } 42 | const businessDaysResponseTime = calcResponseTimeForIssueCreatedAt(context.payload.issue.created_at); 43 | console.log("response time in business days: " + businessDaysResponseTime); 44 | const result = osmetadata(context, context.payload.issue).set('response_time_in_business_days', businessDaysResponseTime) 45 | console.log("osmetadata update result: " + result); 46 | return "set response time in business days: " + businessDaysResponseTime; 47 | } 48 | -------------------------------------------------------------------------------- /.github/workflows/Zapier.yml: -------------------------------------------------------------------------------- 1 | # This is an action to close asana tasks that were generated by Github issues 2 | 3 | name: Zapier web hook 4 | 5 | # Controls when the workflow will run 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the "main" branch 8 | issues: 9 | types: [closed] 10 | 11 | permissions: 12 | issues: read 13 | 14 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 15 | jobs: 16 | # This workflow contains a single job called "build" 17 | build: 18 | # The type of runner that the job will run on 19 | runs-on: ubuntu-latest 20 | 21 | # Steps represent a sequence of tasks that will be executed as part of the job 22 | steps: 23 | # Runs a set of commands using the runners shell 24 | - name: Call Zapier web hook to close Asana task 25 | if: ${{ !github.event.issue.pull_request }} 26 | env: 27 | ISSUE_TITLE: ${{ github.event.issue.title }} 28 | run: | 29 | curl --location --request POST 'https://hooks.zapier.com/hooks/catch/12728683/b7009qc/' \ 30 | --header 'Content-Type: application/json' \ 31 | --header 'Accept: application/json' \ 32 | --data-raw '{ 33 | "task_name" : "$ISSUE_TITLE" 34 | }' 35 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | pull_request: 5 | branches: '**' 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-24.04 10 | steps: 11 | - uses: actions/checkout@v4 12 | - name: '[Setup] Node' 13 | uses: actions/setup-node@v4 14 | with: 15 | node-version: 16 16 | - name: '[Setup] Dependencies' 17 | run: yarn 18 | - name: '[Test] Linting' 19 | run: yarn lint 20 | 21 | - name: Unit tests results 22 | if: failure() 23 | uses: actions/upload-artifact@v4 24 | with: 25 | name: unit-tests-results 26 | path: . 27 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ "main", "major_release_5.0.0" ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ "main", "major_release_5.0.0" ] 20 | schedule: 21 | - cron: '37 19 * * 4' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | # Runner size impacts CodeQL analysis time. To learn more, please see: 27 | # - https://gh.io/recommended-hardware-resources-for-running-codeql 28 | # - https://gh.io/supported-runners-and-hardware-resources 29 | # - https://gh.io/using-larger-runners 30 | # Consider using larger runners for possible analysis time improvements. 31 | runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} 32 | timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} 33 | permissions: 34 | actions: read 35 | contents: read 36 | security-events: write 37 | 38 | strategy: 39 | fail-fast: false 40 | matrix: 41 | language: [ 'javascript-typescript' ] 42 | # CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ] 43 | # Use only 'java-kotlin' to analyze code written in Java, Kotlin or both 44 | # Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both 45 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support 46 | 47 | steps: 48 | - name: Checkout repository 49 | uses: actions/checkout@v3 50 | 51 | # Initializes the CodeQL tools for scanning. 52 | - name: Initialize CodeQL 53 | uses: github/codeql-action/init@v2 54 | with: 55 | languages: ${{ matrix.language }} 56 | # If you wish to specify custom queries, you can do so here or in a config file. 57 | # By default, queries listed here will override any specified in a config file. 58 | # Prefix the list here with "+" to use these queries and those in the config file. 59 | 60 | # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 61 | # queries: security-extended,security-and-quality 62 | 63 | 64 | # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). 65 | # If this step fails, then you should remove it and run the build manually (see below) 66 | - name: Autobuild 67 | uses: github/codeql-action/autobuild@v2 68 | 69 | # ℹ️ Command-line programs to run using the OS shell. 70 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 71 | 72 | # If the Autobuild fails above, remove it and uncomment the following three lines. 73 | # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. 74 | 75 | # - run: | 76 | # echo "Run, Build Application using script" 77 | # ./location_of_script_within_repo/buildscript.sh 78 | 79 | - name: Perform CodeQL Analysis 80 | uses: github/codeql-action/analyze@v2 81 | with: 82 | category: "/language:${{matrix.language}}" 83 | -------------------------------------------------------------------------------- /.github/workflows/npm_deploy.yml: -------------------------------------------------------------------------------- 1 | name: NPM Publish 2 | 3 | on: 4 | release: 5 | types: [created] 6 | 7 | jobs: 8 | publish: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - uses: actions/setup-node@v3 13 | with: 14 | node-version: 18 15 | - name: Publish package 16 | uses: JS-DevTools/npm-publish@v1 17 | with: 18 | token: ${{ secrets.NPM }} 19 | -------------------------------------------------------------------------------- /.github/workflows/project.yml: -------------------------------------------------------------------------------- 1 | name: Add issues to project 2 | on: 3 | issues: 4 | types: 5 | - opened 6 | 7 | jobs: 8 | add-to-project: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Add issue to project 12 | uses: actions/add-to-project@v1.0.2 13 | with: 14 | # SDK Cross-Platform Project 15 | project-url: https://github.com/orgs/OneSignal/projects/10 16 | github-token: ${{ secrets.GH_PROJECTS_TOKEN }} 17 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | # branches to consider in the event; optional, defaults to all 6 | branches: 7 | - main 8 | # pull_request event is required only for autolabeler 9 | pull_request: 10 | # Only following types are handled by the action, but one can default to all as well 11 | types: [opened, reopened, synchronize] 12 | # pull_request_target event is required for autolabeler to support PRs from forks 13 | # pull_request_target: 14 | # types: [opened, reopened, synchronize] 15 | 16 | permissions: 17 | contents: read 18 | 19 | jobs: 20 | update_release_draft: 21 | permissions: 22 | # write permission is required to create a github release 23 | contents: write 24 | # write permission is required for autolabeler 25 | # otherwise, read permission is required at least 26 | pull-requests: write 27 | runs-on: ubuntu-latest 28 | steps: 29 | # (Optional) GitHub Enterprise requires GHE_HOST variable set 30 | #- name: Set GHE_HOST 31 | # run: | 32 | # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV 33 | 34 | # Drafts your next Release notes as Pull Requests are merged into "master" 35 | - uses: release-drafter/release-drafter@v5 36 | # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml 37 | # with: 38 | # config-name: my-config.yml 39 | # disable-autolabeler: true 40 | env: 41 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 42 | -------------------------------------------------------------------------------- /.github/workflows/set_response_time.yml: -------------------------------------------------------------------------------- 1 | name: Set Response Time 2 | on: 3 | issue_comment: 4 | types: 5 | - created 6 | issues: 7 | types: 8 | - closed 9 | jobs: 10 | calculate: 11 | name: set reponse time for the issue 12 | if: github.event.issue.pull_request == null 13 | runs-on: ubuntu-latest 14 | permissions: 15 | issues: write 16 | steps: 17 | - uses: actions/checkout@v3 18 | with: 19 | token: ${{ secrets.GITHUB_TOKEN }} 20 | - run: npm install @octokit/action@6.0.6 21 | - uses: actions/github-script@v6 22 | id: set-time 23 | with: 24 | result-encoding: string 25 | script: | 26 | const os_probot_metadata = require('./.github/os_probot_metadata.js') 27 | const set_response_time = require('./.github/set_response_times.js') 28 | return await set_response_time(context, os_probot_metadata) 29 | env: 30 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 31 | - name: Get result 32 | run: echo "${{steps.set-time.outputs.result}}" >> $GITHUB_STEP_SUMMARY 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # node.js 2 | # 3 | node_modules/ 4 | npm-debug.log 5 | yarn-error.log 6 | 7 | # jest 8 | coverage/ 9 | 10 | # tsc 11 | # 12 | dist 13 | 14 | # OSX 15 | # 16 | .DS_Store 17 | examples/.DS_Store 18 | 19 | # examples node_modules 20 | # 21 | examples/CocoapodsDemo/node_modules 22 | examples/RNOneSignal/node_modules 23 | *.iml 24 | local.properties 25 | 26 | # examples android device Data 27 | # 28 | examples/CocoapodsDemo/android/app/build 29 | examples/CocoapodsDemo/android/.gradle 30 | examples/CocoapodsDemo/android/.idea 31 | examples/CocoapodsDemo/android/build 32 | examples/RNOneSignalTS/android/app/build 33 | examples/RNOneSignalTS/android/app/debug.keystore 34 | examples/RNOneSignalTS/android/.gradle 35 | examples/RNOneSignalTS/android/.idea 36 | examples/RNOneSignalTS/android/build 37 | 38 | # examples iOS data 39 | # 40 | examples/CocoapodsDemo/ios/CocoapodsDemo.xcodeproj/project.xcworkspace/xcshareddata 41 | examples/CocoapodsDemo/ios/CocoapodsDemo.xcodeproj/project.xcworkspace/xcuserdata 42 | examples/CocoapodsDemo/ios/CocoapodsDemo.xcodeproj/xcuserdata 43 | examples/CocoapodsDemo/ios/CocoapodsDemo.xcworkspace/xcshareddata 44 | examples/CocoapodsDemo/ios/CocoapodsDemo.xcworkspace/xcuserdata 45 | examples/CocoapodsDemo/ios/Pods/Pods.xcodeproj/xcuserdata 46 | examples/RNOneSignalTS/ios/RNOneSignal.xcodeproj/project.xcworkspace/xcshareddata 47 | examples/RNOneSignalTS/ios/RNOneSignal.xcodeproj/project.xcworkspace/xcuserdata 48 | examples/RNOneSignalTS/ios/RNOneSignal.xcodeproj/xcuserdata 49 | examples/RNOneSignalTS/ios/RNOneSignal.xcworkspace/xcshareddata 50 | examples/RNOneSignalTS/ios/RNOneSignal.xcworkspace/xcuserdata 51 | examples/RNOneSignal/ios/Pods/Pods.xcodeproj/xcuserdata 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | examples 2 | images 3 | .git -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: true, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | }; 7 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to the OneSignal React-Native SDK 2 | 3 | :+1::tada: First off, thanks for taking the time to contribute! :tada::+1: 4 | 5 | ### How to Contribute 6 | 7 | We love the open source community and enjoy the support and contributions of many of our users. We ask that any potential contributors to the SDK Follow the following guidelines: 8 | 9 | If your proposed contribution is a small bug fix, please feel free to create your own fork of the repository and create a pull request. 10 | 11 | If your contribution would _break_ or _change_ the functionality of the SDK, please reach out to us on (contact) before you put in a lot of effort into a change we may not be able to use. We try our best to make sure that the SDK remains stable so that developers do not have to continually change their code, however some breaking changes _are_ desirable, so please get in touch to discuss your idea before you put in a lot of effort. 12 | 13 | #### Reporting Bugs 14 | 15 | If you have found a bug with the SDK, please feel free to open an Issue. 16 | 17 | If you are pretty certain that the issue is only related to the native iOS SDK, please open the issue in our [native iOS SDK repository](https://github.com/OneSignal/OneSignal-iOS-SDK). 18 | 19 | If you are certain the issue is contained to the Android SDK, please open the issue in our [Android SDK repository](https://github.com/OneSignal/OneSignal-Android-SDK) 20 | 21 | #### Before Submitting A Bug Report 22 | 23 | Before creating bug reports, please check this list of steps to follow. 24 | 25 | 1. Make sure that you are actually encountering an _issue_ and not a _question_. If you simply have a question about the SDK, we would be more than happy to assist you in our Support section on the web (https://www.onesignal.com - click the Message button at the bottom right) 26 | 2. Please make sure to [include as many details as possible](#how-do-i-submit-a-good-bug-report) 27 | 28 | > **Note:** If you find a **Closed** issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one. 29 | 30 | #### How Do I Submit a Good Bug Report 31 | 32 | - **Use a clear and descriptive title** for the issue to identify the problem. 33 | - **Include Reproducibility** It is nearly always a good idea to include steps to reproduct the issue. If you cannot reliably reproduce the issue yourself, that's ok, but reproducible steps help best. 34 | - **Describe your environment**, tell us what version of react-native your app is using, what version of the react-native-onesignal SDK you're using, how you added it to your project, and so on. 35 | - **Include a Stack Trace** If your issue involves a crash/exception, **_PLEASE_** post the stack trace to help us identify the root issue. 36 | - **Include an Example Project** This isn't required, but if you want your issue fixed quickly, it's often a good idea to include an example project as a zip and include it with the issue. You can also download the Demo project (included in the `/examples` folder of this repo) and set up an example project with this code as a starting point. 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Modified MIT License 2 | 3 | Copyright 2019 OneSignal 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | 1. The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | 2. All copies of substantial portions of the Software may only be used in connection 16 | with services provided by OneSignal. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | ### React Native OneSignal SDK 6 | 7 | [![npm version](https://img.shields.io/npm/v/react-native-onesignal.svg)](https://www.npmjs.com/package/react-native-onesignal) [![npm downloads](https://img.shields.io/npm/dm/react-native-onesignal.svg)](https://www.npmjs.com/package/react-native-onesignal) 8 | 9 | --- 10 | 11 | #### ⚠️ Migration Advisory for current OneSignal customers 12 | 13 | Our new [user-centric APIs and v5.x.x SDKs](https://onesignal.com/blog/unify-your-users-across-channels-and-devices/) offer an improved user and data management experience. However, they may not be at 1:1 feature parity with our previous versions yet. 14 | 15 | If you are migrating an existing app, we suggest using iOS and Android’s Phased Rollout capabilities to ensure that there are no unexpected issues or edge cases. Here is the documentation for each: 16 | 17 | - [iOS Phased Rollout](https://developer.apple.com/help/app-store-connect/update-your-app/release-a-version-update-in-phases/) 18 | - [Google Play Staged Rollouts](https://support.google.com/googleplay/android-developer/answer/6346149?hl=en) 19 | 20 | If you run into any challenges or have concerns, please contact our support team at support@onesignal.com 21 | 22 | --- 23 | 24 | [OneSignal](https://onesignal.com/) is a free email, sms, push notification, and in-app message service for mobile apps. This SDK makes it easy to integrate your native React-Native iOS and/or Android apps with OneSignal. 25 | 26 | #### Installation 27 | 28 | See the [Setup Guide](https://documentation.onesignal.com/docs/react-native-sdk-setup) for setup instructions. 29 | 30 | #### Change Log 31 | 32 | See this repository's [release tags](https://github.com/OneSignal/react-native-onesignal/releases) for a complete change log of every released version. 33 | 34 | #### Support 35 | 36 | Please visit this repository's [Github issue tracker](https://github.com/OneSignal/react-native-onesignal/issues) for feature requests and bug reports related specifically to the SDK. 37 | For account issues and support please contact OneSignal support from the [OneSignal.com](https://onesignal.com) dashboard. 38 | 39 | #### Demo Project 40 | 41 | To make things easier, we have published demo projects in the `/examples` folder of this repository. 42 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | def safeExtGet(prop, fallback) { 4 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback 5 | } 6 | 7 | android { 8 | compileSdkVersion safeExtGet('compileSdkVersion', 28) 9 | buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3') 10 | 11 | defaultConfig { 12 | minSdkVersion safeExtGet('minSdkVersion', 16) 13 | } 14 | buildTypes { 15 | release { 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | 20 | compileOptions { 21 | sourceCompatibility JavaVersion.VERSION_1_8 22 | targetCompatibility JavaVersion.VERSION_1_8 23 | } 24 | } 25 | 26 | dependencies { 27 | implementation fileTree(include: ['*.jar'], dir: 'libs') 28 | implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}" 29 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4" 30 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4" 31 | 32 | // api is used instead of implementation so the parent :app project can access any of the OneSignal Java 33 | // classes if needed. Such as com.onesignal.NotificationExtenderService 34 | api 'com.onesignal:OneSignal:5.1.34' 35 | 36 | testImplementation 'junit:junit:4.12' 37 | } -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneSignal/react-native-onesignal/d56b9869a649346e3df37e94c5334462476daf52/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 6 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /android/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.4.1_1/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 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /android/src/main/java/com/onesignal/rnonesignalandroid/RNUtils.java: -------------------------------------------------------------------------------- 1 | package com.onesignal.rnonesignalandroid; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import com.facebook.react.bridge.Arguments; 6 | import com.facebook.react.bridge.ReadableArray; 7 | import com.facebook.react.bridge.ReadableMap; 8 | import com.facebook.react.bridge.ReadableMapKeySetIterator; 9 | import com.facebook.react.bridge.ReadableType; 10 | import com.facebook.react.bridge.WritableArray; 11 | import com.facebook.react.bridge.WritableMap; 12 | import com.facebook.react.bridge.WritableNativeArray; 13 | import com.facebook.react.bridge.WritableNativeMap; 14 | 15 | import com.onesignal.inAppMessages.IInAppMessage; 16 | import com.onesignal.inAppMessages.IInAppMessageClickEvent; 17 | import com.onesignal.inAppMessages.IInAppMessageClickResult; 18 | import com.onesignal.inAppMessages.IInAppMessageWillDisplayEvent; 19 | import com.onesignal.inAppMessages.IInAppMessageDidDisplayEvent; 20 | import com.onesignal.inAppMessages.IInAppMessageWillDismissEvent; 21 | import com.onesignal.inAppMessages.IInAppMessageDidDismissEvent; 22 | import com.onesignal.notifications.INotification; 23 | import com.onesignal.notifications.INotificationWillDisplayEvent; 24 | import com.onesignal.notifications.INotificationClickEvent; 25 | import com.onesignal.notifications.INotificationClickResult; 26 | import com.onesignal.notifications.INotificationReceivedEvent; 27 | import com.onesignal.user.subscriptions.IPushSubscription; 28 | import com.onesignal.user.subscriptions.PushSubscriptionState; 29 | import com.onesignal.user.subscriptions.PushSubscriptionChangedState; 30 | import com.onesignal.user.state.UserState; 31 | import com.onesignal.user.state.UserChangedState; 32 | 33 | import org.json.JSONArray; 34 | import org.json.JSONException; 35 | import org.json.JSONObject; 36 | import java.util.Iterator; 37 | import java.util.HashMap; 38 | import java.util.Map; 39 | import java.util.List; 40 | import javax.annotation.Nullable; 41 | 42 | public class RNUtils { 43 | public static WritableMap convertHashMapToWritableMap(HashMap hashMap) throws JSONException { 44 | WritableMap writableMap = Arguments.createMap(); 45 | for (Map.Entry entry : hashMap.entrySet()) { 46 | String key = entry.getKey(); 47 | Object value = entry.getValue(); 48 | 49 | if (value instanceof String) { 50 | writableMap.putString(key, (String) value); 51 | } else if (value instanceof Boolean) { 52 | writableMap.putBoolean(key, (Boolean) value); 53 | } else if (value instanceof Integer) { 54 | writableMap.putInt(key, (Integer) value); 55 | } else if (value instanceof Double) { 56 | writableMap.putDouble(key, (Double) value); 57 | } else if (value instanceof Float) { 58 | writableMap.putDouble(key, ((Float) value).doubleValue()); 59 | } else if (value instanceof Long) { 60 | writableMap.putDouble(key, ((Long) value).doubleValue()); 61 | } else if (value instanceof HashMap) { 62 | writableMap.putMap(key, convertHashMapToWritableMap((HashMap) value)); 63 | } else { 64 | writableMap.putNull(key); 65 | } 66 | } 67 | return writableMap; 68 | } 69 | 70 | public static HashMap convertNotificationClickEventToMap(INotificationClickEvent event) throws JSONException { 71 | HashMap clickResultHash = new HashMap<>(); 72 | HashMap hash = new HashMap<>(); 73 | HashMap notificationHash = convertNotificationToMap(event.getNotification()); 74 | INotificationClickResult clickResult = event.getResult(); 75 | 76 | clickResultHash.put("actionId", clickResult.getActionId()); 77 | clickResultHash.put("url", clickResult.getUrl()); 78 | 79 | hash.put("notification", notificationHash); 80 | hash.put("result", clickResultHash); 81 | 82 | return hash; 83 | } 84 | 85 | public static HashMap convertNotificationToMap(INotification notification) throws JSONException { 86 | HashMap notificationHash = new HashMap<>(); 87 | notificationHash.put("androidNotificationId", notification.getAndroidNotificationId()); 88 | 89 | if (notification.getGroupedNotifications() != null) { 90 | notificationHash.put("groupKey", notification.getGroupKey()); 91 | notificationHash.put("groupMessage", notification.getGroupMessage()); 92 | notificationHash.put("groupedNotifications", notification.getGroupedNotifications()); 93 | } 94 | 95 | notificationHash.put("notificationId", notification.getNotificationId()); 96 | notificationHash.put("title", notification.getTitle()); 97 | 98 | if (notification.getBody() != null) 99 | notificationHash.put("body", notification.getBody()); 100 | if (notification.getSmallIcon() != null) 101 | notificationHash.put("smallIcon", notification.getSmallIcon()); 102 | if (notification.getLargeIcon() != null) 103 | notificationHash.put("largeIcon", notification.getLargeIcon()); 104 | if (notification.getBigPicture() != null) 105 | notificationHash.put("bigPicture", notification.getBigPicture()); 106 | if (notification.getSmallIconAccentColor() != null) 107 | notificationHash.put("smallIconAccentColor", notification.getSmallIconAccentColor()); 108 | if (notification.getLaunchURL() != null) 109 | notificationHash.put("launchURL", notification.getLaunchURL()); 110 | if (notification.getSound() != null) 111 | notificationHash.put("sound", notification.getSound()); 112 | if (notification.getLedColor() != null) 113 | notificationHash.put("ledColor", notification.getLedColor()); 114 | notificationHash.put("lockScreenVisibility", notification.getLockScreenVisibility()); 115 | if (notification.getGroupKey() != null) 116 | notificationHash.put("groupKey", notification.getGroupKey()); 117 | if (notification.getGroupMessage() != null) 118 | notificationHash.put("groupMessage", notification.getGroupMessage()); 119 | if (notification.getFromProjectNumber() != null) 120 | notificationHash.put("fromProjectNumber", notification.getFromProjectNumber()); 121 | if (notification.getCollapseId() != null) 122 | notificationHash.put("collapseId", notification.getCollapseId()); 123 | notificationHash.put("priority", notification.getPriority()); 124 | if (notification.getAdditionalData() != null && notification.getAdditionalData().length() > 0) 125 | notificationHash.put("additionalData", convertJSONObjectToHashMap(notification.getAdditionalData())); 126 | if (notification.getActionButtons() != null) { 127 | notificationHash.put("actionButtons", notification.getActionButtons()); 128 | } 129 | notificationHash.put("rawPayload", notification.getRawPayload()); 130 | 131 | return notificationHash; 132 | } 133 | 134 | private static HashMap convertInAppMessageToMap(IInAppMessage message) { 135 | HashMap hash = new HashMap<>(); 136 | hash.put("messageId", message.getMessageId()); 137 | 138 | return hash; 139 | } 140 | 141 | public static HashMap convertInAppMessageWillDisplayEventToMap(IInAppMessageWillDisplayEvent event) { 142 | HashMap hash = new HashMap<>(); 143 | hash.put("message", convertInAppMessageToMap(event.getMessage())); 144 | 145 | return hash; 146 | } 147 | 148 | public static HashMap convertInAppMessageDidDisplayEventToMap(IInAppMessageDidDisplayEvent event) { 149 | HashMap hash = new HashMap<>(); 150 | hash.put("message", convertInAppMessageToMap(event.getMessage())); 151 | 152 | return hash; 153 | } 154 | 155 | public static HashMap convertInAppMessageWillDismissEventToMap(IInAppMessageWillDismissEvent event) { 156 | HashMap hash = new HashMap<>(); 157 | hash.put("message", convertInAppMessageToMap(event.getMessage())); 158 | 159 | return hash; 160 | } 161 | 162 | public static HashMap convertInAppMessageDidDismissEventToMap(IInAppMessageDidDismissEvent event) { 163 | HashMap hash = new HashMap<>(); 164 | hash.put("message", convertInAppMessageToMap(event.getMessage())); 165 | 166 | return hash; 167 | } 168 | 169 | public static HashMap convertInAppMessageClickEventToMap(IInAppMessageClickEvent event) { 170 | HashMap resultHash = new HashMap<>(); 171 | HashMap hash = new HashMap<>(); 172 | IInAppMessageClickResult result = event.getResult(); 173 | 174 | resultHash.put("actionId", result.getActionId()); 175 | resultHash.put("urlTarget", result.getUrlTarget()); 176 | resultHash.put("url", result.getUrl()); 177 | resultHash.put("closingMessage", result.getClosingMessage()); 178 | 179 | hash.put("result", resultHash); 180 | hash.put("message", convertInAppMessageToMap(event.getMessage())); 181 | 182 | return hash; 183 | } 184 | 185 | public static HashMap convertPushSubscriptionStateToMap(PushSubscriptionState state) { 186 | HashMap hash = new HashMap<>(); 187 | if (state.getToken() != null && !state.getToken().isEmpty()) { 188 | hash.put("token", state.getToken()); 189 | } else { 190 | hash.put("token", JSONObject.NULL); 191 | } 192 | if (state.getId() != null && !state.getId().isEmpty()) { 193 | hash.put("id", state.getId()); 194 | } else { 195 | hash.put("id", JSONObject.NULL); 196 | } 197 | hash.put("optedIn", state.getOptedIn()); 198 | 199 | return hash; 200 | } 201 | 202 | public static HashMap convertUserStateToMap(UserState user) { 203 | HashMap hash = new HashMap<>(); 204 | 205 | if (user.getExternalId() != null && !user.getExternalId().isEmpty()) { 206 | hash.put("externalId", user.getExternalId()); 207 | } 208 | else { 209 | hash.put("externalId", JSONObject.NULL); 210 | } 211 | if (user.getOnesignalId() != null && !user.getOnesignalId().isEmpty()) { 212 | hash.put("onesignalId", user.getOnesignalId()); 213 | } 214 | else { 215 | hash.put("onesignalId", JSONObject.NULL); 216 | } 217 | 218 | return hash; 219 | } 220 | 221 | public static HashMap convertPushSubscriptionChangedStateToMap(PushSubscriptionChangedState state) { 222 | HashMap hash = new HashMap<>(); 223 | hash.put("current", convertPushSubscriptionStateToMap(state.getCurrent())); 224 | hash.put("previous", convertPushSubscriptionStateToMap(state.getPrevious())); 225 | 226 | return hash; 227 | } 228 | 229 | public static HashMap convertUserChangedStateToMap(UserChangedState state) { 230 | HashMap hash = new HashMap<>(); 231 | hash.put("current", convertUserStateToMap(state.getCurrent())); 232 | 233 | return hash; 234 | } 235 | 236 | public static HashMap convertJSONObjectToHashMap(JSONObject object) throws JSONException { 237 | HashMap hash = new HashMap<>(); 238 | 239 | if (object == null || object == JSONObject.NULL) 240 | return hash; 241 | 242 | Iterator keys = object.keys(); 243 | 244 | while (keys.hasNext()) { 245 | String key = keys.next(); 246 | 247 | if (object.isNull(key)) 248 | continue; 249 | 250 | Object val = object.get(key); 251 | 252 | if (val instanceof JSONArray) { 253 | val = convertJSONArrayToList((JSONArray)val); 254 | } else if (val instanceof JSONObject) { 255 | val = convertJSONObjectToHashMap((JSONObject)val); 256 | } 257 | 258 | hash.put(key, val); 259 | } 260 | 261 | return hash; 262 | } 263 | 264 | public static Collection convertReadableArrayIntoStringCollection(ReadableArray readableArray) { 265 | ArrayList strings = new ArrayList<>(); 266 | for (Object object : readableArray.toArrayList()) { 267 | if (object instanceof String) 268 | strings.add((String) object); 269 | } 270 | return strings; 271 | } 272 | 273 | public static HashMap convertReadableMapIntoStringMap(ReadableMap readableMap) { 274 | HashMap stringMap = new HashMap<>(); 275 | ReadableMapKeySetIterator iter = readableMap.keySetIterator(); 276 | 277 | while (iter.hasNextKey()) { 278 | String propKey = iter.nextKey(); 279 | if (readableMap.getType(propKey) == ReadableType.String) { 280 | stringMap.put(propKey, readableMap.getString(propKey)); 281 | } 282 | } 283 | 284 | return stringMap; 285 | } 286 | 287 | public static HashMap convertPermissionToMap(boolean granted) { 288 | HashMap hash = new HashMap<>(); 289 | 290 | hash.put("permission", granted); 291 | 292 | return hash; 293 | } 294 | 295 | private static List convertJSONArrayToList(JSONArray array) throws JSONException { 296 | List list = new ArrayList<>(); 297 | 298 | for (int i = 0; i < array.length(); i++) { 299 | Object val = array.get(i); 300 | 301 | if (val instanceof JSONArray) 302 | val = RNUtils.convertJSONArrayToList((JSONArray)val); 303 | else if (val instanceof JSONObject) 304 | val = convertJSONObjectToHashMap((JSONObject)val); 305 | 306 | list.add(val); 307 | } 308 | 309 | return list; 310 | } 311 | } 312 | -------------------------------------------------------------------------------- /android/src/main/java/com/onesignal/rnonesignalandroid/ReactNativeOneSignalPackage.java: -------------------------------------------------------------------------------- 1 | package com.onesignal.rnonesignalandroid; 2 | 3 | import com.facebook.react.ReactPackage; 4 | import com.facebook.react.bridge.JavaScriptModule; 5 | import com.facebook.react.bridge.NativeModule; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.uimanager.ViewManager; 8 | 9 | import java.util.ArrayList; 10 | import java.util.Collections; 11 | import java.util.List; 12 | import java.util.Arrays; 13 | 14 | public class ReactNativeOneSignalPackage implements ReactPackage { 15 | @Override 16 | public List createNativeModules(ReactApplicationContext reactContext) { 17 | return Arrays.asList(new RNOneSignal(reactContext)); 18 | } 19 | 20 | // Deprecated RN 0.47 21 | public List> createJSModules() { 22 | return Collections.emptyList(); 23 | } 24 | 25 | @Override 26 | public List 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 |