Google Cloud Messaging for React Native
Install
install react-native-gcm
$ npm install react-native-gcm
Add GCM Pod to your Podfile
pod Google/CloudMessaging`
Add Source files to your project
GCM.swift
GCMBridge.h
GCMBridge.m
Add ObjC / Swift Bridge Header
#import "RCTBridge.h"
#import "RCTBridgeModule.h"
#import "RCTEventDispatcher.h"
#import <Google/CloudMessaging.h>
Usage
;
Register for Push Notifications
// Default permission {alert: true, badge: true, sound: true}gcm
Set App Badge Value
// Set App Badge to valuegcm; // Increment App Badge valuegcm;
Get App Badge Value
gcm;
Subscribe to topic
gcm;
Unsubscribe from topic
gcm;
Send upstream message
gcm;
Events
GCM has all "EventEmitter" methods.
// Connected to GCM socketgcm; // Disconnected from GCM socketgcm; // Client registered with gcmgcm; // Application entered backgroundgcm; // Application became active againgcm; // Received message from GCMgcm;
License
MIT