pdcnotification

package module
v0.0.0-...-d15974d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

README

pdcnotification

endpoint

untuk endpoint production tanya ke developer. untuk running lokal go run cmd/main.go

payload endpoint

{
	action: 'send_action' | 'add_token'
	email: string
	message: string
	token: string[]
}

snippet install pligin

<script>
  var exports = {"__esModule": true}
</script>
<script type="module" src="/script.js"></script>
<script>
window.pdcnotification.initializeNotification('user@gmail.com')
</script>

deploy tutorial

  • gcloud functions deploy Notification --runtime go116 --trigger-http --allow-unauthenticated

localhost firebase

<script type="module">
  // Import the functions you need from the SDKs you need
  import { initializeApp } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-app.js";
  import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-analytics.js";
  // TODO: Add SDKs for Firebase products that you want to use
  // https://firebase.google.com/docs/web/setup#available-libraries

  // Your web app's Firebase configuration
  // For Firebase JS SDK v7.20.0 and later, measurementId is optional
  const firebaseConfig = {
    apiKey: "AIzaSyB-bvRwNZAWRCKEFVTxE-gErCE0Kg2YmX8",
    authDomain: "pdc-base.firebaseapp.com",
    projectId: "pdc-base",
    storageBucket: "pdc-base.appspot.com",
    messagingSenderId: "671716308705",
    appId: "1:671716308705:web:3a39142eb8eba6712ba9a0",
    measurementId: "G-71XRDCZDYE"
  };

  // Initialize Firebase
  const app = initializeApp(firebaseConfig);
  const analytics = getAnalytics(app);
</script>

Documentation

Index

Constants

View Source
const (
	UserNotFound   ResponseErrorCode = "user_not_found"
	UserExist                        = "user_exist"
	Success                          = "success"
	SendNotifError                   = "send_notif_error"
	AddTokenError                    = "add_token_error"
)

Variables

This section is empty.

Functions

func Notification

func Notification(w http.ResponseWriter, r *http.Request)

Types

type ActionNotif

type ActionNotif string
const (
	SendAction     ActionNotif = "send_action"
	AddTokenAction             = "add_token"
)

type Payload

type Payload struct {
	Action  ActionNotif `json:"action"`
	Email   string      `json:"email"`
	Message string      `json:"message"`
	Tokens  []string    `json:"tokens"`
}

type Response

type Response struct {
	Errcode ResponseErrorCode `json:"errcode"`
	Message string            `json:"message"`
}

func (Response) ReturnData

func (res Response) ReturnData(w io.Writer)

type ResponseErrorCode

type ResponseErrorCode string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL