Skip to content

Commit 2d50d92

Browse files
committed
Updates from Tue 24 Mar
- [ReactNative] Open Source PushNotifications and move Badge Number methods and permission into it | Tadeu Zagallo - [react-packager] Fix regression with transform errors | Amjad Masad - Flowify TextStylePropTypes and fix a bug with unsupported props | Marshall Roch - [ReactNative] Remove `arc build` instructions from require | Alex Kotliarskyi - Flowify Library/Utilities/ | Marshall Roch - [react-packager] Default to index.js from main if it's a dir | Amjad Masad
1 parent c676e9d commit 2d50d92

38 files changed

Lines changed: 837 additions & 245 deletions

Examples/UIExplorer/AppStateExample.js

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* @flow
10+
*/
11+
'use strict';
12+
13+
var React = require('react-native');
14+
var {
15+
AlertIOS,
16+
PushNotificationIOS,
17+
StyleSheet,
18+
Text,
19+
TouchableHighlight,
20+
View,
21+
} = React;
22+
23+
var Button = React.createClass({
24+
render: function() {
25+
return (
26+
<TouchableHighlight
27+
underlayColor={'white'}
28+
style={styles.button}
29+
onPress={this.props.onPress}>
30+
<Text style={styles.buttonLabel}>
31+
{this.props.label}
32+
</Text>
33+
</TouchableHighlight>
34+
);
35+
}
36+
});
37+
38+
class NotificationExample extends React.Component {
39+
componentWillMount() {
40+
PushNotificationIOS.addEventListener('notification', this._onNotification);
41+
}
42+
43+
componentWillUnmount() {
44+
PushNotificationIOS.removeEventListener('notification', this._onNotification);
45+
}
46+
47+
render() {
48+
return (
49+
<View>
50+
<Button
51+
onPress={this._sendNotification}
52+
label="Send fake notification"
53+
/>
54+
</View>
55+
);
56+
}
57+
58+
_sendNotification() {
59+
require('RCTDeviceEventEmitter').emit('remoteNotificationReceived', {
60+
aps: {
61+
alert: 'Sample notification',
62+
badge: '+1',
63+
sound: 'default',
64+
category: 'REACT_NATIVE'
65+
},
66+
});
67+
}
68+
69+
_onNotification(notification) {
70+
AlertIOS.alert(
71+
'Notification Received',
72+
`Alert message: ${notification.getMessage()}`,
73+
[{
74+
text: 'Dismiss',
75+
onPress: null,
76+
}]
77+
);
78+
}
79+
}
80+
81+
class NotificationPermissionExample extends React.Component {
82+
constructor(props) {
83+
super(props);
84+
this.state = {permissions: null};
85+
}
86+
87+
render() {
88+
return (
89+
<View>
90+
<Button
91+
onPress={this._showPermissions.bind(this)}
92+
label="Show enabled permissions"
93+
/>
94+
<Text>
95+
{JSON.stringify(this.state.permissions)}
96+
</Text>
97+
</View>
98+
);
99+
}
100+
101+
_showPermissions() {
102+
PushNotificationIOS.checkPermissions((permissions) => {
103+
this.setState({permissions});
104+
});
105+
}
106+
}
107+
108+
var styles = StyleSheet.create({
109+
button: {
110+
padding: 10,
111+
alignItems: 'center',
112+
justifyContent: 'center',
113+
},
114+
buttonLabel: {
115+
color: 'blue',
116+
},
117+
});
118+
119+
exports.title = 'PushNotificationIOS';
120+
exports.description = 'Apple PushNotification and badge value';
121+
exports.examples = [
122+
{
123+
title: 'Badge Number',
124+
render(): React.Component {
125+
PushNotificationIOS.requestPermissions();
126+
127+
return (
128+
<View>
129+
<Button
130+
onPress={() => PushNotificationIOS.setApplicationIconBadgeNumber(42)}
131+
label="Set app's icon badge to 42"
132+
/>
133+
<Button
134+
onPress={() => PushNotificationIOS.setApplicationIconBadgeNumber(0)}
135+
label="Clear app's icon badge"
136+
/>
137+
</View>
138+
);
139+
},
140+
},
141+
{
142+
title: 'Push Notifications',
143+
render(): React.Component {
144+
return <NotificationExample />;
145+
}
146+
},
147+
{
148+
title: 'Notifications Permissions',
149+
render(): React.Component {
150+
return <NotificationPermissionExample />;
151+
}
152+
}];

Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
2222
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
2323
147CED4C1AB3532B00DA3E4C /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 147CED4B1AB34F8C00DA3E4C /* libRCTActionSheet.a */; };
24+
14DC67F41AB71881001358AB /* libRCTPushNotification.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14DC67F11AB71876001358AB /* libRCTPushNotification.a */; };
2425
D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */; };
2526
/* End PBXBuildFile section */
2627

@@ -88,6 +89,13 @@
8889
remoteGlobalIDString = 134814201AA4EA6300B7C361;
8990
remoteInfo = RCTActionSheet;
9091
};
92+
14DC67F01AB71876001358AB /* PBXContainerItemProxy */ = {
93+
isa = PBXContainerItemProxy;
94+
containerPortal = 14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */;
95+
proxyType = 2;
96+
remoteGlobalIDString = 134814201AA4EA6300B7C361;
97+
remoteInfo = RCTPushNotification;
98+
};
9199
D85B829B1AB6D5CE003F4FE2 /* PBXContainerItemProxy */ = {
92100
isa = PBXContainerItemProxy;
93101
containerPortal = D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */;
@@ -116,6 +124,7 @@
116124
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = UIExplorer/Images.xcassets; sourceTree = "<group>"; };
117125
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = UIExplorer/Info.plist; sourceTree = "<group>"; };
118126
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = UIExplorer/main.m; sourceTree = "<group>"; };
127+
14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTPushNotification.xcodeproj; path = ../../Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj; sourceTree = "<group>"; };
119128
14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = ../../Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj; sourceTree = "<group>"; };
120129
D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = ../../Libraries/Vibration/RCTVibration.xcodeproj; sourceTree = "<group>"; };
121130
/* End PBXFileReference section */
@@ -135,6 +144,7 @@
135144
00D2771C1AB8C55500DC1E48 /* libicucore.dylib in Frameworks */,
136145
00D2771A1AB8C3E100DC1E48 /* libRCTWebSocketDebugger.a in Frameworks */,
137146
D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */,
147+
14DC67F41AB71881001358AB /* libRCTPushNotification.a in Frameworks */,
138148
147CED4C1AB3532B00DA3E4C /* libRCTActionSheet.a in Frameworks */,
139149
134454601AAFCABD003F0779 /* libRCTAdSupport.a in Frameworks */,
140150
134A8A2A1AACED7A00945AAE /* libRCTGeolocation.a in Frameworks */,
@@ -177,6 +187,7 @@
177187
isa = PBXGroup;
178188
children = (
179189
D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */,
190+
14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */,
180191
14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */,
181192
13417FFA1AA91531003F314A /* ReactKit.xcodeproj */,
182193
134454551AAFCAAE003F0779 /* RCTAdSupport.xcodeproj */,
@@ -259,6 +270,14 @@
259270
name = Products;
260271
sourceTree = "<group>";
261272
};
273+
14DC67E81AB71876001358AB /* Products */ = {
274+
isa = PBXGroup;
275+
children = (
276+
14DC67F11AB71876001358AB /* libRCTPushNotification.a */,
277+
);
278+
name = Products;
279+
sourceTree = "<group>";
280+
};
262281
83CBB9F61A601CBA00E9B192 = {
263282
isa = PBXGroup;
264283
children = (
@@ -371,6 +390,10 @@
371390
ProductGroup = 134180271AA91779003F314A /* Products */;
372391
ProjectRef = 134180261AA91779003F314A /* RCTNetwork.xcodeproj */;
373392
},
393+
{
394+
ProductGroup = 14DC67E81AB71876001358AB /* Products */;
395+
ProjectRef = 14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */;
396+
},
374397
{
375398
ProductGroup = 13417FEB1AA914B8003F314A /* Products */;
376399
ProjectRef = 13417FEA1AA914B8003F314A /* RCTText.xcodeproj */;
@@ -453,6 +476,13 @@
453476
remoteRef = 147CED4A1AB34F8C00DA3E4C /* PBXContainerItemProxy */;
454477
sourceTree = BUILT_PRODUCTS_DIR;
455478
};
479+
14DC67F11AB71876001358AB /* libRCTPushNotification.a */ = {
480+
isa = PBXReferenceProxy;
481+
fileType = archive.ar;
482+
path = libRCTPushNotification.a;
483+
remoteRef = 14DC67F01AB71876001358AB /* PBXContainerItemProxy */;
484+
sourceTree = BUILT_PRODUCTS_DIR;
485+
};
456486
D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */ = {
457487
isa = PBXReferenceProxy;
458488
fileType = archive.ar;

Examples/UIExplorer/UIExplorerList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ var APIS = [
4848
require('./ActionSheetIOSExample'),
4949
require('./AdSupportIOSExample'),
5050
require('./AlertIOSExample'),
51-
require('./AppStateExample'),
5251
require('./AppStateIOSExample'),
5352
require('./AsyncStorageExample'),
5453
require('./CameraRollExample.ios'),
5554
require('./GeolocationExample'),
5655
require('./LayoutExample'),
5756
require('./NetInfoExample'),
5857
require('./PointerEventsExample'),
58+
require('./PushNotificationIOSExample'),
5959
require('./StatusBarIOSExample'),
6060
require('./TimerExample'),
6161
require('./VibrationIOSExample'),

Libraries/AppState/AppState.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)