Skip to content

Instantly share code, notes, and snippets.

View tjkang's full-sized avatar

TJ Kang tjkang

  • Seoul, South Korea
View GitHub Profile
@tjkang
tjkang / App.js
Last active October 5, 2018 13:09
Push Notification for React Native
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
StyleSheet,
Text,
@tjkang
tjkang / SubjectListScene.js
Created March 23, 2017 03:35
Sending a push notification from the RN App
_onPress = () => {
const subjectsRef = firebase.database().ref('subjects');
const notificationReqsRef = firebase.database().ref('notificationRequests');
const subjectData = {
author: 'TJ',
title: this.state.subjectText,
};
const notificationReq = {
from_username: 'TJ',
message: `just posted new topic "${this.state.topicText}"`,
@tjkang
tjkang / app.js
Created March 23, 2017 03:49
AppServer code for Push Notification
var firebase = require('firebase-admin');
var request = require('request');
// Fetch the service account key JSON file contents
var serviceAccount = require("path/to/serviceAccountKey.json");
var env = require("path/to/env.json");
// Your Firebase Cloud Messaging Server API key
var API_KEY = env.CLOUD_MESSAGE_API_KEY;
@tjkang
tjkang / login.js
Created March 23, 2017 04:11
subscribe and unsubscribe to topic for push notification
import React, { Component } from 'react';
import { View, StyleSheet, Text } from 'react-native';
import { Actions } from 'react-native-router-flux';
import FCM from 'react-native-fcm';
.....
_onLoginSuccess = () => {
const topic = '/topics/list'
FCM.subscribeToTopic(topic); // subscribe to topic
@tjkang
tjkang / index.js
Created March 23, 2017 15:24
Cloud Function for Push Notification
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
/**
* Triggers when new subject added in the list and sends a notification.
*/
exports.sendNotification = functions.database.ref('/subjects/{subjectKey}').onWrite((event) => {
@tjkang
tjkang / Fastfile
Last active August 11, 2017 16:46
Fastfile recipes for Beta_Crashlytics
fastlane_version "2.25.0"
default_platform :ios
platform :ios do
lane :beta do |values|
# Before calling match, we make sure all our devices are registered on the Apple Developer Portal
register_devices(
devices_file: "./fastlane/devices.txt",
username: 'user@abc.com'
@tjkang
tjkang / .travis.xml
Last active April 6, 2018 01:28
travis.xml for android
language: android
jdk: oraclejdk8
sudo: required
dist: precise
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
yarn: true
directories:
.....
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
.......
@tjkang
tjkang / Fastfile
Created April 6, 2018 01:36
Fastfile for android
desc "Submit a new Beta Build to Crashlytics Beta"
lane :beta do |values|
# Adjust the `build_type` and `flavor` params as needed to build the right APK for your setup
emails = values[:test_email] ? values[:test_email] : ['tj@abc.com'] # You can list more emails here
groups = values[:test_email] ? nil : nil # You can define groups on the web and reference them here
gradle(
task: "assembleRelease",
git_url "git@github.com:***/certificates.git" # ssh key
type "development" # The default type, can be: appstore, adhoc, enterprise or development
app_identifier "com.kangsta.smapleApp"
username "tj@***.com" # Your Apple Developer Portal username