Skip to content

Commit

Permalink
gitpkg
Browse files Browse the repository at this point in the history
  • Loading branch information
Anders Friis committed Jan 7, 2020
0 parents commit b516662
Show file tree
Hide file tree
Showing 30 changed files with 2,904 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ignore_dirs": [
"node_modules"
]
}
32 changes: 32 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Apache-2.0 License
------------------

Copyright (c) 2016-present Invertase Limited <[email protected]> & Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this library except in compliance with the License.

You may obtain a copy of the Apache-2.0 License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


Creative Commons Attribution 3.0 License
----------------------------------------

Copyright (c) 2016-present Invertase Limited <[email protected]> & Contributors

Documentation and other instructional materials provided for this project
(including on a separate documentation repository or it's documentation website) are
licensed under the Creative Commons Attribution 3.0 License. Code samples/blocks
contained therein are licensed under the Apache License, Version 2.0 (the "License"), as above.

You may obtain a copy of the Creative Commons Attribution 3.0 License at

https://creativecommons.org/licenses/by/3.0/
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<p align="center">
<a href="https://invertase.io/oss/react-native-firebase">
<img width="160px" src="https://i.imgur.com/JIyBtKW.png"><br/>
</a>
<h2 align="center">React Native Firebase - Messaging</h2>
</p>

<p align="center">
<a href="https://api.rnfirebase.io/coverage/messaging/detail"><img src="https://api.rnfirebase.io/coverage/messaging/badge?style=flat-square" alt="Coverage"></a>
<a href="https://www.npmjs.com/package/@react-native-firebase/messaging"><img src="https://img.shields.io/npm/dm/@react-native-firebase/messaging.svg?style=flat-square" alt="NPM downloads"></a>
<a href="https://www.npmjs.com/package/@react-native-firebase/messaging"><img src="https://img.shields.io/npm/v/@react-native-firebase/messaging.svg?style=flat-square" alt="NPM version"></a>
<a href="/LICENSE"><img src="https://img.shields.io/npm/l/react-native-firebase.svg?style=flat-square" alt="License"></a>
<a href="https://lerna.js.org/"><img src="https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg?style=flat-square" alt="Maintained with Lerna"></a>
</p>

<p align="center">
<a href="https://invertase.link/discord"><img src="https://img.shields.io/discord/295953187817521152.svg?style=flat-square&colorA=7289da&label=Chat%20on%20Discord" alt="Chat on Discord"></a>
<a href="https://twitter.com/rnfirebase"><img src="https://img.shields.io/twitter/follow/rnfirebase.svg?style=flat-square&colorA=1da1f2&colorB=&label=Follow%20on%20Twitter" alt="Follow on Twitter"></a>
<a href="https://www.facebook.com/groups/rnfirebase"><img src="https://img.shields.io/badge/Follow%20on%20Facebook-4172B8?logo=facebook&style=flat-square&logoColor=fff" alt="Follow on Facebook"></a>
</p>

----

React Native Firebase provides native integration of Firebase Cloud Messaging (FCM) for both Android & iOS. FCM is a
cost free service, allowing for server-device and device-device communication.
The React Native Firebase Messaging module provides a simple JavaScript API to
interact with FCM.

[> Learn More](https://firebase.google.com/products/cloud-messaging/)

## Installation

Requires `@react-native-firebase/app` to be installed.

```bash
yarn add @react-native-firebase/messaging
```

## Documentation

- [Quick Start](https://invertase.io/oss/react-native-firebase/v6/messaging/quick-start)
- [Guides](https://invertase.io/oss/react-native-firebase/guides?tags=messaging)
- [Reference](https://invertase.io/oss/react-native-firebase/v6/messaging/reference)

## License

- See [LICENSE](/LICENSE)

----

<p>
<img align="left" width="75px" src="https://static.invertase.io/assets/invertase-logo-small.png">
<p align="left">
Built and maintained with 💛 by <a href="https://invertase.io">Invertase</a>.
</p>
<p align="left">
<a href="https://invertase.io/hire-us">💼 Hire Us</a> |
<a href="https://opencollective.com/react-native-firebase">☕️ Sponsor Us</a> |
<a href="https://opencollective.com/jobs">‍💻 Work With Us</a>
</p>
</p>

----
29 changes: 29 additions & 0 deletions RNFBMessaging.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

firebase_sdk_version = '~> 6.13.0'
using_custom_firebase_sdk_version = defined? $FirebaseSDKVersion
if using_custom_firebase_sdk_version
Pod::UI.puts "RNFBMessaging: Using user specified Firebase SDK version '#{$FirebaseSDKVersion}'"
firebase_sdk_version = $FirebaseSDKVersion
end

Pod::Spec.new do |s|
s.name = "RNFBMessaging"
s.version = package["version"]
s.description = package["description"]
s.summary = <<-DESC
A well tested feature rich Firebase implementation for React Native, supporting iOS & Android.
DESC
s.homepage = "http://invertase.io/oss/react-native-firebase"
s.license = package['license']
s.authors = "Invertase Limited"
s.source = { :git => "https://github.com/invertase/react-native-firebase.git", :tag => "v#{s.version}" }
s.social_media_url = 'http://twitter.com/invertaseio'
s.ios.deployment_target = "9.0"
s.source_files = 'ios/**/*.{h,m}'
s.dependency 'React'
s.dependency 'Firebase/Messaging', firebase_sdk_version
s.dependency 'RNFBApp'
s.static_framework = false
end
10 changes: 10 additions & 0 deletions android/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# editorconfig
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
79 changes: 79 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
buildscript {
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
// module dependency in an application project.
if (project == rootProject) {
repositories {
google()
jcenter()
}

dependencies {
classpath("com.android.tools.build:gradle:3.5.2")
}
}
}

plugins {
id "io.invertase.gradle.build" version "1.3"
}

project.ext {
set('react-native', [
versions: [
android : [
minSdk : 16,
targetSdk : 28,
compileSdk: 28,
// optional as gradle.buildTools comes with one by default
// overriding here though to match the version RN uses
buildTools: "28.0.3"
],

firebase: [
bom: "24.1.0",
],
],
])
}

apply from: file("./../../app/android/firebase-json.gradle")
def autoInitEnabled = "true"
if (rootProject.ext && rootProject.ext.firebaseJson) {
if (rootProject.ext.firebaseJson.isFlagEnabled("messaging_auto_init_enabled") == false) {
autoInitEnabled = "false"
}
}

android {
defaultConfig {
multiDexEnabled true
manifestPlaceholders = [
firebaseJsonAutoInitEnabled: autoInitEnabled
]
}
lintOptions {
disable 'GradleCompatible'
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

repositories {
google()
jcenter()
}

dependencies {
api project(':@react-native-firebase_app')
implementation platform("com.google.firebase:firebase-bom:${ReactNative.ext.getVersion("firebase", "bom")}")
implementation "com.google.firebase:firebase-messaging"
}

ReactNative.shared.applyPackageVersion()
ReactNative.shared.applyDefaultExcludes()
ReactNative.module.applyAndroidVersions()
ReactNative.module.applyReactNativeDependency("api")
5 changes: 5 additions & 0 deletions android/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<!-- Disable the given check in this project -->
<issue id="GradleCompatible" severity="ignore" />
</lint>
1 change: 1 addition & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = '@react-native-firebase_messaging'
39 changes: 39 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.invertase.firebase.messaging">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application>
<service android:name="io.invertase.firebase.messaging.ReactNativeFirebaseMessagingHeadlessService" />
<service android:name="io.invertase.firebase.messaging.ReactNativeFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<meta-data
android:name="firebase_messaging_auto_init_enabled"
android:value="${firebaseJsonAutoInitEnabled}"/>

<!-- TODO move below TODOs to Notifcations module -->
<!-- TODO firebase.json -->
<!-- Set custom default icon. This is used when no icon is set for incoming notification messages.
See README(https://goo.gl/l4GJaQ) for more. -->
<!-- <meta-data-->
<!-- android:name="com.google.firebase.messaging.default_notification_icon"-->
<!-- android:resource="@drawable/ic_stat_ic_notification"/>-->
<!-- TODO firebase.json -->
<!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
notification message. See README(https://goo.gl/6BKBk7) for more. -->
<!-- <meta-data-->
<!-- android:name="com.google.firebase.messaging.default_notification_color"-->
<!-- android:resource="@color/colorAccent"/>-->
<!-- TODO firebase.json -->
<!-- <meta-data-->
<!-- android:name="com.google.firebase.messaging.default_notification_channel_id"-->
<!-- android:value="@string/default_notification_channel_id"/>-->
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.invertase.firebase.messaging;

import android.content.Intent;
import android.os.Bundle;
import com.facebook.react.HeadlessJsTaskService;
import com.facebook.react.jstasks.HeadlessJsTaskConfig;
import com.google.firebase.messaging.RemoteMessage;
import io.invertase.firebase.common.ReactNativeFirebaseJSON;

import javax.annotation.Nullable;

public class ReactNativeFirebaseMessagingHeadlessService extends HeadlessJsTaskService {
private static final long TIMEOUT_DEFAULT = 60000;
private static final String TIMEOUT_JSON_KEY = "messaging_android_headless_task_timeout";
private static final String TASK_KEY = "ReactNativeFirebaseMessagingHeadlessTask";

@Override
protected @Nullable
HeadlessJsTaskConfig getTaskConfig(Intent intent) {
Bundle extras = intent.getExtras();
if (extras == null) return null;
RemoteMessage remoteMessage = intent.getParcelableExtra("message");

return new HeadlessJsTaskConfig(
TASK_KEY,
ReactNativeFirebaseMessagingSerializer.remoteMessageToWritableMap(remoteMessage),
ReactNativeFirebaseJSON.getSharedInstance().getLongValue(TIMEOUT_JSON_KEY, TIMEOUT_DEFAULT),
false
);
}
}
Loading

0 comments on commit b516662

Please sign in to comment.