New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-ua

Package Overview
Dependencies
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-ua - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

android/src/main/java/com/globo/reactnativeua/ReactNativeUAReceiverHelper.java

33

index.js

@@ -22,3 +22,4 @@ import {

'alert': notification.alert,
'data': notification.data
'data': notification.data,
'url': notification.url
});

@@ -33,2 +34,4 @@ }

NativeAppEventEmitter.addListener('receivedNotification', (notification) => {
var action_url = notification.data['^u'] || false;
call_notification_listeners({

@@ -38,3 +41,4 @@ 'platform': 'ios',

'alert': notification.data.aps.alert,
'data': notification.data
'data': notification.data,
'url': action_url
});

@@ -49,2 +53,6 @@ });

DeviceEventEmitter.addListener('receivedNotification', (notification) => {
var actions_json = notification['com.urbanairship.actions'] || false;
var actions = actions_json ? JSON.parse(actions_json) : false;
var action_url = actions ? actions['^u'] || false : false;
call_notification_listeners({

@@ -54,3 +62,4 @@ 'platform': 'android',

'alert': notification['com.urbanairship.push.ALERT'],
'data': notification
'data': notification,
'url': action_url
});

@@ -73,2 +82,18 @@ });

static enable_geolocation () {
bridge.enableGeolocation();
}
static enable_action_url () {
bridge.enableActionUrl();
}
static disable_action_url () {
bridge.disableActionUrl();
}
static handle_background_notification () {
bridge.handleBackgroundNotification();
}
static add_tag (tag) {

@@ -82,3 +107,3 @@ bridge.addTag(tag);

static setNamedUserId (nameUserId) {
static set_named_user_id (nameUserId) {
bridge.setNamedUserId(nameUserId);

@@ -85,0 +110,0 @@ }

2

package.json
{
"name": "react-native-ua",
"version": "0.0.4",
"version": "0.0.5",
"description": "React Native module for Urban Airship platforms: iOS and Android",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -98,3 +98,3 @@ # React Native Module for Urban Airship

4. Inside `MainActivity.java`, located at `android/app/src/main/java/your/app/domain`, add the `ReactNativeUAPackage` to your app package list:
4. Inside `MainApplication.java`, located at `android/app/src/main/java/your/app/domain`, add the `ReactNativeUAPackage` to your app package list:

@@ -106,5 +106,7 @@ ```java

public class MainActivity extends ReactActivity {
public class MainApplication extends Application implements ReactApplication {
// ...
public final Application application = this; // get application
@Override

@@ -114,3 +116,3 @@ protected List<ReactPackage> getPackages() {

// ...
new ReactNativeUAPackage(this.getApplication()) // add react-native-ua package
new ReactNativeUAPackage(application) // set react-native-ua package using application
);

@@ -161,3 +163,3 @@ }

8. Inside `AppDelegate.m`, import `ReactNativeUAIOS.h` and call the module with `[ReactNativeUAIOS setupUrbanAirship]`. Follow the example below:
8. Inside `AppDelegate.m`, import `ReactNativeUAIOS.h` and call the module with `[ReactNativeUAIOS setupUrbanAirship:launchOptions]`. Follow the example below:

@@ -174,3 +176,3 @@ ```objective-c

// setup react native urban airship
[ReactNativeUAIOS setupUrbanAirship];
[ReactNativeUAIOS setupUrbanAirship:launchOptions];

@@ -184,9 +186,19 @@ // ...

```
9. To enable location add this two string keys with their values inside Info.plist:
- NSLocationAlwaysUsageDescription: Urban Airship location service
- NSLocationWhenInUseUsageDescription: Urban Airship location service when app is in use
## Methods
- **[ReactNativeUA.enable_notification()](https://github.com/globocom/react-native-ua/blob/master/index.js#L60)**: Prompt user to enable notification receivement;
- **[ReactNativeUA.disable_notification()](https://github.com/globocom/react-native-ua/blob/master/index.js#L64)**: Prompt user to disable notification receivement;
- **[ReactNativeUA.add_tag("tag")](https://github.com/globocom/react-native-ua/blob/master/index.js#L68)**: Set tag to the user;
- **[ReactNativeUA.remove_tag("tag")](https://github.com/globocom/react-native-ua/blob/master/index.js#L72)**: Remove added tag;
- **[ReactNativeUA.on_notification((notification) => {})](https://github.com/globocom/react-native-ua/blob/master/index.js#L76)**: Add handler to handle all incoming notifications. **Attention:** this method need to be called on `componentWillMount()` of the component lifecycle.
- **[ReactNativeUA.enable_notification()](https://github.com/globocom/react-native-ua/blob/master/index.js#L63)**: Prompt user to enable notification receivement;
- **[ReactNativeUA.disable_notification()](https://github.com/globocom/react-native-ua/blob/master/index.js#L67)**: Prompt user to disable notification receivement;
- **[ReactNativeUA.enable_geolocation()](https://github.com/globocom/react-native-ua/blob/master/index.js#L71)**: Prompt user to enable geolocation;
- **[ReactNativeUA.enable_action_url()](https://github.com/globocom/react-native-ua/blob/master/index.js#L75)**: Enable url action. The app will open the default browser with passed url;
- **[ReactNativeUA.disable_action_url()](https://github.com/globocom/react-native-ua/blob/master/index.js#L79)**: Disable url action (Default). The notification handler will receive payload with a `url` property;
- **[ReactNativeUA.handle_background_notification()](https://github.com/globocom/react-native-ua/blob/master/index.js#L83)**: Handle notifications when app is in background;
- **[ReactNativeUA.add_tag("tag")](https://github.com/globocom/react-native-ua/blob/master/index.js#L87)**: Set tag to the user;
- **[ReactNativeUA.remove_tag("tag")](https://github.com/globocom/react-native-ua/blob/master/index.js#L91)**: Remove added tag;
- **[ReactNativeUA.set_named_user_id("nameUserId")](https://github.com/globocom/react-native-ua/blob/master/index.js#L95)**: Set named user id;
- **[ReactNativeUA.on_notification((notification) => {})](https://github.com/globocom/react-native-ua/blob/master/index.js#L99)**: Add handler to handle all incoming notifications. **Attention:** this method need to be called on `componentWillMount()` of the component lifecycle.

@@ -209,13 +221,19 @@ ## Usage

constructor (props) {
super(props);
render () {
ReactNativeUA.enable_notification(); // prompt user to enable notification
}
componentWillMount () {
ReactNativeUA.enable_geolocation(); // prompt user to enable geolocation
ReactNativeUA.enable_action_url(); // enable url action
ReactNativeUA.handle_background_notification(); // handle notifications when app is in background
ReactNativeUA.add_tag('tag'); // set tag to the user
ReactNativeUA.set_named_user_id('user_id'); // set named user id
// add handler to handle all incoming notifications
ReactNativeUA.on_notification((notification) => {
console.log('notification:',
notification.url, // if action url is disabled
notification.platform,

@@ -228,5 +246,3 @@ notification.event,

});
}
render () {
return (

@@ -233,0 +249,0 @@ <View>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc