Skip to content

Instantly share code, notes, and snippets.

View sample secret.gradle
ext {
// google credentials
apiKey = "GOOGLE_API_KEY"
clientId = "GOOGLE_CLIENT_ID"
// google authorization adapter service
@skiph
skiph / rndemo-Bridging-Header.h
Created May 9, 2018
rndemo ios-swift bridging header
View rndemo-Bridging-Header.h
// rndemo rndemo-Bridging-Header.h
#import <React/RCTBridgeModule.h>
@skiph
skiph / ApproovBridge.m
Created May 9, 2018
rndemo - native bridge implementation
View ApproovBridge.m
#import <React/RCTBridgeModule.h>
@interface RCT_EXTERN_MODULE(Approov, NSObject)
RCT_EXTERN_METHOD(fetchApproovToken:(NSString *)url
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject
)
@end
@skiph
skiph / Approov.swift
Created May 9, 2018
rndemo: swift bridging class
View Approov.swift
import Foundation
import Approov
@objc(Approov)
class Approov: NSObject {
@objc func fetchApproovToken(_ url: String,
resolver resolve: @escaping RCTPromiseResolveBlock,
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
let attestee = ApproovAttestee.shared()
@skiph
skiph / ApproovPackage.java
Last active May 2, 2018
RNDemo - Approov Package
View ApproovPackage.java
package com.criticalblue.approov;
import ...
public class ApproovPackage implements ReactPackage {
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
@skiph
skiph / Approov.js
Last active May 2, 2018
RNDemo - Approov module wrapper
View Approov.js
import {NativeModules} from 'react-native';
const fetchWithToken = (input, options) => {
return NativeModules.Approov.fetchApproovToken(input)
.then(token => {
let optionsA = (options? {...options, headers:{ ...options.headers}}:{headers: {}});
optionsA.headers['Approov-Token'] = token;
return fetch(input, optionsA)
.then((response) => {
@skiph
skiph / AppFragment.js
Last active May 2, 2018
RNDemo - App getShape fragment
View AppFragment.js
import Approov from './Approov';
class App extends React.Component {
// unchanged code ommitted for brevity...
// get shape
getShape = () => {
Approov.fetch('https://demo-server.approovr.io/shapes', {
@skiph
skiph / native-module-call.js
Last active May 2, 2018
RNDemo - native module call
View native-module-call.js
import {NativeModules} from 'react-native';
NativeModules.Approov.fetchApproovToken(input)
.then(token => {
// do something useful...
})
.catch((error) => {
throw error;
});
@skiph
skiph / App.js
Last active Apr 27, 2018
RNDemo - Say Hello
View App.js
import React from 'react';
import { View, Image, Text, Button, StyleSheet } from 'react-native';
import ShapeView from './ShapeView'
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {shape: 'logo',
status: ''};
}
@skiph
skiph / ApproovModule.java
Last active Apr 27, 2018
RNDemo - Approov native module
View ApproovModule.java
package com.criticalblue.approov;
import ...
import com.criticalblue.attestationlibrary.ApproovAttestation;
import com.criticalblue.attestationlibrary.ApproovConfig;
import com.criticalblue.attestationlibrary.TokenInterface;
class ApproovModule extends ReactContextBaseJavaModule {