Skip to content

Commit

Permalink
Merge pull request #77 from VocaDB/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
up2code authored Oct 14, 2018
2 parents dbec619 + 48632bb commit 056adcb
Show file tree
Hide file tree
Showing 16 changed files with 370 additions and 41 deletions.
70 changes: 70 additions & 0 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import i18n from './src/common/i18n';
import nativeI18N from 'react-native-i18n';
import moment from 'moment';
import 'moment/min/locales';
import firebase from 'react-native-firebase';

const uiTheme = {
palette: {
Expand Down Expand Up @@ -67,6 +68,75 @@ class App extends React.Component {

componentWillMount () {
moment.locale(chooseMomentLocale(nativeI18N.currentLocale()));
this.getToken();
this.initFirebase();
firebase.messaging().subscribeToTopic('artist_1');
}

getToken() {
firebase.messaging().getToken()
.then(fcmToken => {
console.log(`token : ${fcmToken}`)
});
}

initFirebase() {

firebase.messaging().hasPermission()
.then(enabled => {

console.log('is enabled? : ' + enabled)
if (!enabled) {
firebase.messaging().requestPermission()
.then(() => {
// User has authorised
console.log('user authorised');
})
.catch(error => {
// User has rejected permissions
console.log(error);
});
} else {
console.log('permiossion exists')
}
});

}

componentDidMount() {

this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {
// Process your notification as required
// ANDROID: Remote notifications do not contain the channel ID. You will have to specify this manually if you'd like to re-display the notification.
console.log('onNotificationDisplayed')
console.log(notification)
});
this.notificationListener = firebase.notifications().onNotification((notification) => {
// Process your notification as required
console.log('onNotification')
console.log(notification)
});


this.messageListener = firebase.messaging().onMessage(m => {
// Process your message as required
console.log('onMessage')
console.log(JSON.stringify(m))
});

this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => {
console.log('onNotificationOpened')
console.log(notificationOpen)
});

firebase.messaging().subscribeToTopic('artist_1');
}

componentWillUnmount() {
this.messageListener();
this.notificationDisplayedListener();
this.notificationListener();
this.notificationOpenedListener();
}

render () {
Expand Down
4 changes: 4 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ dependencies {
implementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
transitive = true
}
implementation "com.google.firebase:firebase-messaging:17.3.2"
implementation 'me.leolin:ShortcutBadger:1.1.21@aar'

}

Expand All @@ -175,3 +177,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
14 changes: 14 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" tools:node="remove" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />

<uses-sdk
android:minSdkVersion="16"
Expand All @@ -20,6 +22,17 @@
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.coolappz.Vocadb.provider"
Expand All @@ -33,6 +46,7 @@
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import cl.json.ShareApplication;
import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage; // <-- Add this line
import io.invertase.firebase.fabric.crashlytics.RNFirebaseCrashlyticsPackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage; // <-- Add this line

import java.util.Arrays;
import java.util.List;
Expand All @@ -41,7 +43,9 @@ protected List<ReactPackage> getPackages() {
new RNI18nPackage(),
new RNFirebasePackage(),
new RNFirebaseAnalyticsPackage(),
new RNFirebaseCrashlyticsPackage()
new RNFirebaseCrashlyticsPackage(),
new RNFirebaseMessagingPackage(),
new RNFirebaseNotificationsPackage()
);
}

Expand Down
6 changes: 4 additions & 2 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ target 'VocaDB' do

end

#target 'VocaDB-tvOS' do
#target 'VocaDB-tvOS' dotv
# # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# # use_frameworks!
#
Expand All @@ -35,4 +35,6 @@ end
pod 'Firebase/Core'
pod 'Firebase/Database', '~> 5.3.0'
pod 'Fabric', '~> 1.7.5'
pod 'Crashlytics', '~> 3.10.1'
pod 'Crashlytics', '~> 3.10.1'
pod 'Firebase/RemoteConfig', '~> 5.3.0'
pod 'Firebase/Messaging', '~> 5.3.0'
Loading

0 comments on commit 056adcb

Please sign in to comment.