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 / activity_main.xml
Last active July 3, 2016 08:00
FCM - activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
@jirawatee
jirawatee / FCM.class.php
Last active July 5, 2016 02:42
FCM - FCM.class.php
<?php
class FCM {
public function send_notification($token, $payload_notification, $payload_data) {
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array(
//'registration_ids' => $token,
//'condition' => "'logined' in topics || 'news' in topics",
'to' => '/topics/news',
'priority' => 'normal',
@jirawatee
jirawatee / MainActivity.java
Created July 7, 2016 19:05
Firebase Analytics - MainActivity.java
package com.example.fanalytics;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import com.google.firebase.analytics.FirebaseAnalytics;
public class MainActivity extends AppCompatActivity {
private FirebaseAnalytics mFirebaseAnalytics;
@jirawatee
jirawatee / remote_config_defaults.xml
Created July 12, 2016 18:39
Firebase Remote Config - remote_config_defaults.xml
<?xml version="1.0" encoding="utf-8"?>
<defaultsMap>
<entry>
<key>is_promotion_on</key>
<value>false</value>
</entry>
<entry>
<key>price</key>
@jirawatee
jirawatee / MainActivity.java
Created September 29, 2017 07:47
Firebase Invites - Send invitation via SMS and Email
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"))
.build();
startActivityForResult(intent, REQUEST_INVITE);
@jirawatee
jirawatee / MainActivity.java
Last active September 29, 2017 12:08
Firebase Invites - Send invitation via email
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"))
.setCustomImage(Uri.parse("https://appjoy.org/wp-content/uploads/2016/06/firebase-invites-logo.png"))
.setCallToActionText("Install")
.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
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 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"/>