Skip to content

Instantly share code, notes, and snippets.

View keremcubuk's full-sized avatar
🏠
Working from home

Kerem Cubuk keremcubuk

🏠
Working from home
View GitHub Profile
@keremcubuk
keremcubuk / install-react-intl.txt
Last active May 4, 2020 09:37
React-intl Integration
npx create-react-app my-app
cd my-app
npm install react-intl --save
@keremcubuk
keremcubuk / rn-push.js
Created January 28, 2020 11:41
Local Notification
npm install https://github.com/zo0r/react-native-push-notification --save
// For IOS
npm install https://github.com/react-native-community/react-native-push-notification-ios --save
@keremcubuk
keremcubuk / myscreen.js
Created January 28, 2020 11:40
Local Notification
import React from 'react';
import { View, Button, Text } from 'react-native';
import LocalNotificationService from '../../utils/LocalNotificationService';
// Just init your project root one time.
LocalNotificationService.init();
LocalNotificationService.configure();
export default class App extends React.Component {
notify() {
@keremcubuk
keremcubuk / myscreen.js
Created January 28, 2020 11:39
Local Notification
<Button title="Notify Me" onPress={() => this.notify()} />
@keremcubuk
keremcubuk / myscreen.js
Created January 28, 2020 11:38
Local Notification
notify() {
LocalNotificationService.sendLocalNotification('Notification Title', 'Notification Detail Content');
}
@keremcubuk
keremcubuk / myscreen.js
Created January 28, 2020 11:37
Local Notification
// Import LocalNotificationService:
import LocalNotificationService from '../utils/LocalNotificationService';
// Init LocalNotificationService
// Just init your project root one time.
LocalNotificationService.init();
LocalNotificationService.configure();
@keremcubuk
keremcubuk / LocalNotificationService.js
Created January 28, 2020 11:35
Local Notification Final View
import PushNotification from 'react-native-push-notification';
import { Platform } from 'react-native';
export default class LocalNotificationService {
static init() {
LocalNotificationService.onNotification = notification => {
if (Platform.OS === 'android' && notification.subject != null && notification.subject !== '') {
PushNotification.localNotification({
title: notification.subject,
message: notification.body,
@keremcubuk
keremcubuk / LocalNotificationService.js
Created January 28, 2020 11:34
Local Notification
static cancelAll() {
PushNotification.cancelAllLocalNotifications();
}
@keremcubuk
keremcubuk / LocalNotificationService.js
Created January 28, 2020 11:33
Local Notification
static sendLocalNotification(title, message) {
PushNotification.localNotification({
title, // (optional) // Your content title
message, // (required) // Your content message. It is required for notification.
});
}
@keremcubuk
keremcubuk / LocalNotificationService.js
Created January 28, 2020 11:32
Local Notification
static configure() {
PushNotification.configure({
onNotification: notification => {
if (LocalNotificationService.onNotification) {
LocalNotificationService.onNotification(notification);
}
},
requestPermissions: true,
popInitialNotification: true,
});