Skip to content

Instantly share code, notes, and snippets.

View jirawatee's full-sized avatar
🔥
Better Together

Jirawat Karanwittayakarn jirawatee

🔥
Better Together
View GitHub Profile
@jirawatee
jirawatee / MainActivity.java
Last active September 29, 2017 14:03
Firebase Invites - Send invitation via email with HTML
Intent intent = new AppInviteInvitation.IntentBuilder("Send App Invitation")
.setMessage("Special season for this app is starting now, try it and get 100 baht")
.setDeepLink(Uri.parse("http://example.com/offer/100_baht"))
.setEmailHtmlContent("<a href='%%APPINVITE_LINK_PLACEHOLDER%%'><h1>Check it out here!</h1><img src='https://appjoy.org/wp-content/uploads/2016/06/firebase-invites-logo.png'></a>")
.setEmailSubject("Firebase Invites want to give you 100 baht")
.build();
startActivityForResult(intent, REQUEST_INVITE);
@jirawatee
jirawatee / MainActivity.java
Created September 29, 2017 13:38
Firebase Invites - Callback
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult: requestCode=" + requestCode + ", resultCode=" + resultCode);
if (requestCode == REQUEST_INVITE) {
if (resultCode == RESULT_OK) {
// Get the invitation IDs of all sent messages
String[] ids = AppInviteInvitation.getInvitationIds(resultCode, data);
for (String id : ids) {
@jirawatee
jirawatee / MainActivity.java
Created September 29, 2017 17:46
Firebase Invites -
// Check for App Invite invitations and launch deep-link activity if possible.
// Requires that an Activity is registered in AndroidManifest.xml to handle
// deep-link URLs.
FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent())
.addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
@Override
public void onSuccess(PendingDynamicLinkData data) {
if (data == null) {
Log.d(TAG, "getInvitation: no data");
return;
@jirawatee
jirawatee / AndroidManifest.xml
Created September 29, 2017 18:01
Firebase Invites - Support DeepLink
<activity android:name=".DeepLinkActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="example.com"
android:scheme="http"/>
@jirawatee
jirawatee / DeepLinkActivtiy.class
Created September 29, 2017 18:17
Firebase Invites - Handle DeepLink
FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent())
.addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
@Override
public void onSuccess(PendingDynamicLinkData data) {
if (data == null) {
Log.d(TAG, "getInvitation: no data");
return;
}
Log.d(TAG, "DeepLink: " + data.getLink());
@jirawatee
jirawatee / node.js
Created April 14, 2018 16:18
Functions from Cloud Functions for Firebase triggered by Firebase Crashlytics
'use strict';
const functions = require('firebase-functions');
const request = require('request-promise');
const notifyLine = (lineMessage, stkPkgId, stkId) => {
return request({
method: `POST`,
uri: `https://notify-api.line.me/api/notify`,
headers: {
@jirawatee
jirawatee / flex-contrainer-bubble.json
Last active April 29, 2019 08:44
Bubble contrainer structure in Flex Message
{
"type": "bubble",
"direction": "ltr",
"styles": {
"header": {
"backgroundColor": "#ffaaaa",
},
"body": {
"backgroundColor": "#aaffaa",
"separator": true,
@jirawatee
jirawatee / flex-contrainer-carousel.json
Last active May 8, 2019 09:40
Carousel contrainer structure in Flex Message
@jirawatee
jirawatee / flex-block.json
Created June 8, 2018 06:49
Block structure in Flex Message
{
"type": "bubble",
"header": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "text",
"text": "header"
}
@jirawatee
jirawatee / flex-component-button.json
Created June 8, 2018 07:06
Button structure in Flex Message
{
"type": "bubble",
"body": {
"type": "box",
"layout": "vertical",
"spacing": "md",
"contents": [
{
"type": "button",
"style": "primary",