react-native-ua
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -76,2 +76,6 @@ import { | ||
static setNamedUserId (nameUserId) { | ||
bridge.setNamedUserId(nameUserId); | ||
} | ||
static on_notification (callback) { | ||
@@ -78,0 +82,0 @@ notification_listeners.push(callback); |
{ | ||
"name": "react-native-ua", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "React Native module for Urban Airship platforms: iOS and Android", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,8 +13,9 @@ # React Native Module for Urban Airship | ||
- [Prerequisites](#prerequisites) | ||
- [Android](#android) | ||
- [iOS](#ios) | ||
- [Urban Airship](#urban-airship) | ||
- [Android](#android) | ||
- [iOS](#ios) | ||
- [Urban Airship](#urban-airship) | ||
- [Getting Started](#getting-started) | ||
- [Android setup](#android-setup) | ||
- [Xcode setup](#xcode-setup) | ||
- [Android setup](#android-setup) | ||
- [Xcode setup](#xcode-setup) | ||
- [Methods](#methods) | ||
- [Usage](#usage) | ||
@@ -28,3 +29,3 @@ | ||
- iOS (8+) | ||
- React Native (0.25) | ||
- React Native (0.27) | ||
@@ -180,2 +181,9 @@ ## Prerequisites | ||
``` | ||
## 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. | ||
@@ -185,16 +193,45 @@ ## Usage | ||
```javascript | ||
import React, { Component } from 'react'; | ||
import { | ||
AppRegistry, | ||
Text, | ||
View | ||
} from 'react-native'; | ||
import ReactNativeUA from 'react-native-ua'; // import module | ||
ReactNativeUA.enable_notification(); // prompt user to enable notification | ||
ReactNativeUA.disable_notification(); // prompt user to disable notification | ||
ReactNativeUA.add_tag("tag"); // add only one tag | ||
ReactNativeUA.remove_tag("tag"); // remove only one tag | ||
// add handler to handle all incoming notifications | ||
ReactNativeUA.on_notitication((notification) => { | ||
console.log(notification.platform, | ||
notification.event, | ||
notification.alert, | ||
notification.data); | ||
}); | ||
class SampleApp extends Component { | ||
constructor (props) { | ||
super(props); | ||
ReactNativeUA.enable_notification(); // prompt user to enable notification | ||
} | ||
componentWillMount () { | ||
// add handler to handle all incoming notifications | ||
ReactNativeUA.on_notification((notification) => { | ||
console.log('notification:', | ||
notification.platform, | ||
notification.event, | ||
notification.alert, | ||
notification.data); | ||
alert(notification.alert); | ||
}); | ||
} | ||
render () { | ||
return ( | ||
<View> | ||
<Text>ReactNativeUA</Text> | ||
</View> | ||
); | ||
} | ||
} | ||
AppRegistry.registerComponent('SampleApp', () => SampleApp); | ||
``` |
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
45416534
268
226
234