Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
Merge pull request facebook#190 from vjeux/update12
Browse files Browse the repository at this point in the history
Updates from Tue 24 Mar
  • Loading branch information
vjeux committed Mar 24, 2015
2 parents c676e9d + 2d50d92 commit 2cad104
Show file tree
Hide file tree
Showing 38 changed files with 837 additions and 245 deletions.
67 changes: 0 additions & 67 deletions Examples/UIExplorer/AppStateExample.js

This file was deleted.

152 changes: 152 additions & 0 deletions Examples/UIExplorer/PushNotificationIOSExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
'use strict';

var React = require('react-native');
var {
AlertIOS,
PushNotificationIOS,
StyleSheet,
Text,
TouchableHighlight,
View,
} = React;

var Button = React.createClass({
render: function() {
return (
<TouchableHighlight
underlayColor={'white'}
style={styles.button}
onPress={this.props.onPress}>
<Text style={styles.buttonLabel}>
{this.props.label}
</Text>
</TouchableHighlight>
);
}
});

class NotificationExample extends React.Component {
componentWillMount() {
PushNotificationIOS.addEventListener('notification', this._onNotification);
}

componentWillUnmount() {
PushNotificationIOS.removeEventListener('notification', this._onNotification);
}

render() {
return (
<View>
<Button
onPress={this._sendNotification}
label="Send fake notification"
/>
</View>
);
}

_sendNotification() {
require('RCTDeviceEventEmitter').emit('remoteNotificationReceived', {
aps: {
alert: 'Sample notification',
badge: '+1',
sound: 'default',
category: 'REACT_NATIVE'
},
});
}

_onNotification(notification) {
AlertIOS.alert(
'Notification Received',
`Alert message: ${notification.getMessage()}`,
[{
text: 'Dismiss',
onPress: null,
}]
);
}
}

class NotificationPermissionExample extends React.Component {
constructor(props) {
super(props);
this.state = {permissions: null};
}

render() {
return (
<View>
<Button
onPress={this._showPermissions.bind(this)}
label="Show enabled permissions"
/>
<Text>
{JSON.stringify(this.state.permissions)}
</Text>
</View>
);
}

_showPermissions() {
PushNotificationIOS.checkPermissions((permissions) => {
this.setState({permissions});
});
}
}

var styles = StyleSheet.create({
button: {
padding: 10,
alignItems: 'center',
justifyContent: 'center',
},
buttonLabel: {
color: 'blue',
},
});

exports.title = 'PushNotificationIOS';
exports.description = 'Apple PushNotification and badge value';
exports.examples = [
{
title: 'Badge Number',
render(): React.Component {
PushNotificationIOS.requestPermissions();

return (
<View>
<Button
onPress={() => PushNotificationIOS.setApplicationIconBadgeNumber(42)}
label="Set app's icon badge to 42"
/>
<Button
onPress={() => PushNotificationIOS.setApplicationIconBadgeNumber(0)}
label="Clear app's icon badge"
/>
</View>
);
},
},
{
title: 'Push Notifications',
render(): React.Component {
return <NotificationExample />;
}
},
{
title: 'Notifications Permissions',
render(): React.Component {
return <NotificationPermissionExample />;
}
}];
30 changes: 30 additions & 0 deletions Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
147CED4C1AB3532B00DA3E4C /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 147CED4B1AB34F8C00DA3E4C /* libRCTActionSheet.a */; };
14DC67F41AB71881001358AB /* libRCTPushNotification.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14DC67F11AB71876001358AB /* libRCTPushNotification.a */; };
D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -88,6 +89,13 @@
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTActionSheet;
};
14DC67F01AB71876001358AB /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTPushNotification;
};
D85B829B1AB6D5CE003F4FE2 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */;
Expand Down Expand Up @@ -116,6 +124,7 @@
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = UIExplorer/Images.xcassets; sourceTree = "<group>"; };
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = UIExplorer/Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = UIExplorer/main.m; sourceTree = "<group>"; };
14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTPushNotification.xcodeproj; path = ../../Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj; sourceTree = "<group>"; };
14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = ../../Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj; sourceTree = "<group>"; };
D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = ../../Libraries/Vibration/RCTVibration.xcodeproj; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand All @@ -135,6 +144,7 @@
00D2771C1AB8C55500DC1E48 /* libicucore.dylib in Frameworks */,
00D2771A1AB8C3E100DC1E48 /* libRCTWebSocketDebugger.a in Frameworks */,
D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */,
14DC67F41AB71881001358AB /* libRCTPushNotification.a in Frameworks */,
147CED4C1AB3532B00DA3E4C /* libRCTActionSheet.a in Frameworks */,
134454601AAFCABD003F0779 /* libRCTAdSupport.a in Frameworks */,
134A8A2A1AACED7A00945AAE /* libRCTGeolocation.a in Frameworks */,
Expand Down Expand Up @@ -177,6 +187,7 @@
isa = PBXGroup;
children = (
D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */,
14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */,
14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */,
13417FFA1AA91531003F314A /* ReactKit.xcodeproj */,
134454551AAFCAAE003F0779 /* RCTAdSupport.xcodeproj */,
Expand Down Expand Up @@ -259,6 +270,14 @@
name = Products;
sourceTree = "<group>";
};
14DC67E81AB71876001358AB /* Products */ = {
isa = PBXGroup;
children = (
14DC67F11AB71876001358AB /* libRCTPushNotification.a */,
);
name = Products;
sourceTree = "<group>";
};
83CBB9F61A601CBA00E9B192 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -371,6 +390,10 @@
ProductGroup = 134180271AA91779003F314A /* Products */;
ProjectRef = 134180261AA91779003F314A /* RCTNetwork.xcodeproj */;
},
{
ProductGroup = 14DC67E81AB71876001358AB /* Products */;
ProjectRef = 14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */;
},
{
ProductGroup = 13417FEB1AA914B8003F314A /* Products */;
ProjectRef = 13417FEA1AA914B8003F314A /* RCTText.xcodeproj */;
Expand Down Expand Up @@ -453,6 +476,13 @@
remoteRef = 147CED4A1AB34F8C00DA3E4C /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
14DC67F11AB71876001358AB /* libRCTPushNotification.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTPushNotification.a;
remoteRef = 14DC67F01AB71876001358AB /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
Expand Down
2 changes: 1 addition & 1 deletion Examples/UIExplorer/UIExplorerList.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ var APIS = [
require('./ActionSheetIOSExample'),
require('./AdSupportIOSExample'),
require('./AlertIOSExample'),
require('./AppStateExample'),
require('./AppStateIOSExample'),
require('./AsyncStorageExample'),
require('./CameraRollExample.ios'),
require('./GeolocationExample'),
require('./LayoutExample'),
require('./NetInfoExample'),
require('./PointerEventsExample'),
require('./PushNotificationIOSExample'),
require('./StatusBarIOSExample'),
require('./TimerExample'),
require('./VibrationIOSExample'),
Expand Down
28 changes: 0 additions & 28 deletions Libraries/AppState/AppState.js

This file was deleted.

Loading

0 comments on commit 2cad104

Please sign in to comment.