npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-livesafe

v1.2.3

Published

## Getting started

Downloads

7

Readme

react-native-livesafe

Getting started

$ npm install react-native-livesafe --save

$ react-native link react-native-livesafe

iOS

  1. Add the following Pods to the project's Podfile
  pod 'Alamofire', '4.7.3'
  pod 'SwiftyJSON', '4.1.0'
  pod 'ObjectMapper', '3.3.0'
  pod 'lottie-ios', '2.5.0'
  # pod 'GoogleMaps', '2.6.0' only if using SafeMap
  pod 'SDWebImage', '4.3.2'

alternatively if not using CocoaPods, (or not using use_frameworks! in Podfile, you'll need the framework (.framework) files to be embedded), you can download the binary for each framework and link them manually

  1. pod install

  2. Add the LiveSafe frameworks into embedded binaries

  3. Add the following lines to projectSettings > Target > Build Settings > Framework Search Paths

  "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire"
  "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper"
  "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage"
  "${PODS_ROOT}/GoogleMaps/Maps/Frameworks"
  "${PODS_ROOT}/GoogleMaps/Base/Frameworks"
  "${PODS_CONFIGURATION_BUILD_DIR}/lottie-ios"
  "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON"
  1. After running yarn add react-native-livesafe manually link the xcode project: right click the Libraries folder in your project > Add files > go to node_modules/react-native-livesafe/ios > add the .xcodeproj file

  2. Click the newly added project and in Build Phases remove the old references to Pods and add your own.

  3. In your Target's Build Phases add the libRNLiveSafe.a under Link Binary with Libraries

AppDelegate Config

You'll need to change your AppDelegate to make sure LiveSafe's sdk custom screens can be pushed to your App's UINavigatorViewController.

To start you'll need to change your window.rootViewController to be a UINavigatorViewController instead of a UIViewController. Doing this will make your application show a native navigation bar, to hide this you'll need to create a custom UIViewController class that hides it automatically.

AppDelegate.h
//AppDelegate.h

@interface CustomViewController : UIViewController
- (void) viewDidAppear:(BOOL)animated;
@end

@interface AppDelegate : UIResponder <UIApplicationDelegate, UINavigationControllerDelegate>

@property (nonatomic, strong) UIWindow *window;
@property (nonatomic, strong) CustomViewController *rootViewController;

@end
AppDelegate.m
#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h>

@implementation CustomViewController

- (void) viewWillAppear:(BOOL)animated {
    AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    ((UINavigationController*) delegate.rootViewController).navigationBarHidden = YES;
}

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;
  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"YOUR_APP_MODULE_NAME"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  CustomViewController *rootViewController = [CustomViewController new];
  rootViewController.view = rootView;
  UINavigationController * navController = [[UINavigationController alloc]  initWithRootViewController:rootViewController];
  [navController setDelegate:self];
  self.window.rootViewController = navController;
  self.rootViewController = navController;
  [self.window makeKeyAndVisible];
  return YES;
}

@end

Lastly, make sure you to import your AppDelegate.h in the RNLiveSafe Project's header file.

Android

Add to your project build.gradle file:

allprojects {
    repositories {
				...
        maven {
            url "https://jitpack.io"
            credentials { username "YOUR_JITPACK_API_KEY" }
        }
    }
}

Usage

API

import LiveSafe from 'react-native-livesafe';
LiveSafe.init("YOUR_CLIENT_KEY","YOUR_CLIENT_SECRET");

/**
 * Currently not working on android 
 */
LiveSafe.showMap();

/**
 * Return list of Tips. Check TipType for model
 */
LiveSafe.getTipTypes();

/**
 * Opens activity with history of your tips
 */
LiveSafe.getTipHistory();

/**
 * @param {Object} - tip
 * Check TipType model for excactly what you need to send.
 */
LiveSafe.submitTip(tip);

/**
 * Opens activity for auth
 */
LiveSafe.authentication();

/**
 * @return {Promise} with bool is user logged in
 */
LiveSafe.isLoggedin();

/**
 * @param {String} - number of yout organization security "+122334455"
 */
LiveSafe.callOrganizationSecurity(number);

/**
 * @param {String} - number of yout local security "911"
 */
LiveSafe.callLocalEmergencyService(number);

/**
 * Opens activity for messaging
 */
LiveSafe.messageOrganizationSecurity();
// TipType Model
     *        value - Number - required
     *        name - String - required
     *        icon - String
     *        mapIcon - Number
     *        hintText - String
     *        chatText - String
// Tip Model
     *        text - String - required
     *        isAnonymous - Boolean
     *        dateCreated - Date
     *        longitude - Number
     *        latitude - Number
     *        tipType - Number
     *        uuid - String

Handling notifications on android

As far as I can see, LiveSafe sdk looks for "default" part of message with source = "livesafe". Method handleMessage expects context and Map<String, String>, with second string being the message it self in stringified JSON form. When passing message to bridge method stringify message and pass it as String. Method will convert it to Map with one key="default"

/**
 * {String} - mssg -> JSON.stringify(notification.default || notification.source === 'livesafe)
  */
LiveSafe.handleMessage(mssg)