mirror of
https://github.com/status-im/react-native.git
synced 2025-03-03 10:50:35 +00:00
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
This commit is contained in:
parent
c676e9dccc
commit
2d50d920fa
@ -1,67 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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 {
|
|
||||||
AppState,
|
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var styles = StyleSheet.create({
|
|
||||||
button: {
|
|
||||||
padding: 10,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
},
|
|
||||||
buttonLabel: {
|
|
||||||
color: 'blue',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
exports.title = 'AppState';
|
|
||||||
exports.description = 'App background status and badge value';
|
|
||||||
exports.examples = [
|
|
||||||
{
|
|
||||||
title: 'Set Badge Number',
|
|
||||||
render: function() {
|
|
||||||
return (
|
|
||||||
<View>
|
|
||||||
<Button
|
|
||||||
onPress={() => AppState.setApplicationIconBadgeNumber(42)}
|
|
||||||
label="Set app's icon badge to 42"
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
onPress={() => AppState.setApplicationIconBadgeNumber(0)}
|
|
||||||
label="Clear app's icon badge"
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
}];
|
|
152
Examples/UIExplorer/PushNotificationIOSExample.js
Normal file
152
Examples/UIExplorer/PushNotificationIOSExample.js
Normal file
@ -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 />;
|
||||||
|
}
|
||||||
|
}];
|
@ -21,6 +21,7 @@
|
|||||||
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
|
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
|
||||||
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
|
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
|
||||||
147CED4C1AB3532B00DA3E4C /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 147CED4B1AB34F8C00DA3E4C /* libRCTActionSheet.a */; };
|
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 */; };
|
D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
@ -88,6 +89,13 @@
|
|||||||
remoteGlobalIDString = 134814201AA4EA6300B7C361;
|
remoteGlobalIDString = 134814201AA4EA6300B7C361;
|
||||||
remoteInfo = RCTActionSheet;
|
remoteInfo = RCTActionSheet;
|
||||||
};
|
};
|
||||||
|
14DC67F01AB71876001358AB /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */;
|
||||||
|
proxyType = 2;
|
||||||
|
remoteGlobalIDString = 134814201AA4EA6300B7C361;
|
||||||
|
remoteInfo = RCTPushNotification;
|
||||||
|
};
|
||||||
D85B829B1AB6D5CE003F4FE2 /* PBXContainerItemProxy */ = {
|
D85B829B1AB6D5CE003F4FE2 /* PBXContainerItemProxy */ = {
|
||||||
isa = PBXContainerItemProxy;
|
isa = PBXContainerItemProxy;
|
||||||
containerPortal = D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */;
|
containerPortal = D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */;
|
||||||
@ -116,6 +124,7 @@
|
|||||||
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = UIExplorer/Images.xcassets; sourceTree = "<group>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = ../../Libraries/Vibration/RCTVibration.xcodeproj; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
@ -135,6 +144,7 @@
|
|||||||
00D2771C1AB8C55500DC1E48 /* libicucore.dylib in Frameworks */,
|
00D2771C1AB8C55500DC1E48 /* libicucore.dylib in Frameworks */,
|
||||||
00D2771A1AB8C3E100DC1E48 /* libRCTWebSocketDebugger.a in Frameworks */,
|
00D2771A1AB8C3E100DC1E48 /* libRCTWebSocketDebugger.a in Frameworks */,
|
||||||
D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */,
|
D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */,
|
||||||
|
14DC67F41AB71881001358AB /* libRCTPushNotification.a in Frameworks */,
|
||||||
147CED4C1AB3532B00DA3E4C /* libRCTActionSheet.a in Frameworks */,
|
147CED4C1AB3532B00DA3E4C /* libRCTActionSheet.a in Frameworks */,
|
||||||
134454601AAFCABD003F0779 /* libRCTAdSupport.a in Frameworks */,
|
134454601AAFCABD003F0779 /* libRCTAdSupport.a in Frameworks */,
|
||||||
134A8A2A1AACED7A00945AAE /* libRCTGeolocation.a in Frameworks */,
|
134A8A2A1AACED7A00945AAE /* libRCTGeolocation.a in Frameworks */,
|
||||||
@ -177,6 +187,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */,
|
D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */,
|
||||||
|
14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */,
|
||||||
14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */,
|
14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */,
|
||||||
13417FFA1AA91531003F314A /* ReactKit.xcodeproj */,
|
13417FFA1AA91531003F314A /* ReactKit.xcodeproj */,
|
||||||
134454551AAFCAAE003F0779 /* RCTAdSupport.xcodeproj */,
|
134454551AAFCAAE003F0779 /* RCTAdSupport.xcodeproj */,
|
||||||
@ -259,6 +270,14 @@
|
|||||||
name = Products;
|
name = Products;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
14DC67E81AB71876001358AB /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
14DC67F11AB71876001358AB /* libRCTPushNotification.a */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
83CBB9F61A601CBA00E9B192 = {
|
83CBB9F61A601CBA00E9B192 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -371,6 +390,10 @@
|
|||||||
ProductGroup = 134180271AA91779003F314A /* Products */;
|
ProductGroup = 134180271AA91779003F314A /* Products */;
|
||||||
ProjectRef = 134180261AA91779003F314A /* RCTNetwork.xcodeproj */;
|
ProjectRef = 134180261AA91779003F314A /* RCTNetwork.xcodeproj */;
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ProductGroup = 14DC67E81AB71876001358AB /* Products */;
|
||||||
|
ProjectRef = 14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */;
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ProductGroup = 13417FEB1AA914B8003F314A /* Products */;
|
ProductGroup = 13417FEB1AA914B8003F314A /* Products */;
|
||||||
ProjectRef = 13417FEA1AA914B8003F314A /* RCTText.xcodeproj */;
|
ProjectRef = 13417FEA1AA914B8003F314A /* RCTText.xcodeproj */;
|
||||||
@ -453,6 +476,13 @@
|
|||||||
remoteRef = 147CED4A1AB34F8C00DA3E4C /* PBXContainerItemProxy */;
|
remoteRef = 147CED4A1AB34F8C00DA3E4C /* PBXContainerItemProxy */;
|
||||||
sourceTree = BUILT_PRODUCTS_DIR;
|
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 */ = {
|
D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */ = {
|
||||||
isa = PBXReferenceProxy;
|
isa = PBXReferenceProxy;
|
||||||
fileType = archive.ar;
|
fileType = archive.ar;
|
||||||
|
@ -48,7 +48,6 @@ var APIS = [
|
|||||||
require('./ActionSheetIOSExample'),
|
require('./ActionSheetIOSExample'),
|
||||||
require('./AdSupportIOSExample'),
|
require('./AdSupportIOSExample'),
|
||||||
require('./AlertIOSExample'),
|
require('./AlertIOSExample'),
|
||||||
require('./AppStateExample'),
|
|
||||||
require('./AppStateIOSExample'),
|
require('./AppStateIOSExample'),
|
||||||
require('./AsyncStorageExample'),
|
require('./AsyncStorageExample'),
|
||||||
require('./CameraRollExample.ios'),
|
require('./CameraRollExample.ios'),
|
||||||
@ -56,6 +55,7 @@ var APIS = [
|
|||||||
require('./LayoutExample'),
|
require('./LayoutExample'),
|
||||||
require('./NetInfoExample'),
|
require('./NetInfoExample'),
|
||||||
require('./PointerEventsExample'),
|
require('./PointerEventsExample'),
|
||||||
|
require('./PushNotificationIOSExample'),
|
||||||
require('./StatusBarIOSExample'),
|
require('./StatusBarIOSExample'),
|
||||||
require('./TimerExample'),
|
require('./TimerExample'),
|
||||||
require('./VibrationIOSExample'),
|
require('./VibrationIOSExample'),
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @providesModule AppState
|
|
||||||
*/
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var NativeModules = require('NativeModules');
|
|
||||||
var RCTAppState = NativeModules.AppState;
|
|
||||||
|
|
||||||
var AppState = {
|
|
||||||
|
|
||||||
setApplicationIconBadgeNumber: function(number) {
|
|
||||||
RCTAppState.setApplicationIconBadgeNumber(number);
|
|
||||||
},
|
|
||||||
|
|
||||||
getApplicationIconBadgeNumber: function(callback) {
|
|
||||||
RCTAppState.getApplicationIconBadgeNumber(callback);
|
|
||||||
},
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = AppState;
|
|
@ -7,22 +7,34 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule PushNotificationIOS
|
* @providesModule PushNotificationIOS
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var NativeModules = require('NativeModules');
|
var NativeModules = require('NativeModules');
|
||||||
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
|
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
|
||||||
|
var RCTPushNotificationManager = require('NativeModules').PushNotificationManager;
|
||||||
var RCTPushNotificationManager = NativeModules.PushNotificationManager;
|
var invariant = require('invariant');
|
||||||
if (RCTPushNotificationManager) {
|
|
||||||
var _initialNotification = RCTPushNotificationManager.initialNotification;
|
|
||||||
}
|
|
||||||
|
|
||||||
var _notifHandlers = {};
|
var _notifHandlers = {};
|
||||||
|
var _initialNotification = RCTPushNotificationManager &&
|
||||||
|
RCTPushNotificationManager.initialNotification;
|
||||||
|
|
||||||
var DEVICE_NOTIF_EVENT = 'remoteNotificationReceived';
|
var DEVICE_NOTIF_EVENT = 'remoteNotificationReceived';
|
||||||
|
|
||||||
class PushNotificationIOS {
|
class PushNotificationIOS {
|
||||||
|
_data: Object;
|
||||||
|
_alert: string | Object;
|
||||||
|
_sound: string;
|
||||||
|
_badgeCount: number;
|
||||||
|
|
||||||
|
static setApplicationIconBadgeNumber(number) {
|
||||||
|
RCTPushNotificationManager.setApplicationIconBadgeNumber(number);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getApplicationIconBadgeNumber(callback) {
|
||||||
|
RCTPushNotificationManager.getApplicationIconBadgeNumber(callback);
|
||||||
|
}
|
||||||
|
|
||||||
static addEventListener(type, handler) {
|
static addEventListener(type, handler) {
|
||||||
_notifHandlers[handler] = RCTDeviceEventEmitter.addListener(
|
_notifHandlers[handler] = RCTDeviceEventEmitter.addListener(
|
||||||
@ -33,6 +45,18 @@ class PushNotificationIOS {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static requestPermissions() {
|
||||||
|
RCTPushNotificationManager.requestPermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
static checkPermissions(callback) {
|
||||||
|
invariant(
|
||||||
|
typeof callback === 'function',
|
||||||
|
'Must provide a valid callback'
|
||||||
|
);
|
||||||
|
RCTPushNotificationManager.checkPermissions(callback);
|
||||||
|
}
|
||||||
|
|
||||||
static removeEventListener(type, handler) {
|
static removeEventListener(type, handler) {
|
||||||
if (!_notifHandlers[handler]) {
|
if (!_notifHandlers[handler]) {
|
||||||
return;
|
return;
|
||||||
@ -68,24 +92,24 @@ class PushNotificationIOS {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getMessage() {
|
getMessage(): ?string | ?Object {
|
||||||
// alias because "alert" is an ambiguous name
|
// alias because "alert" is an ambiguous name
|
||||||
return this._alert;
|
return this._alert;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSound() {
|
getSound(): ?string {
|
||||||
return this._sound;
|
return this._sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
getAlert() {
|
getAlert(): ?string | ?Object {
|
||||||
return this._alert;
|
return this._alert;
|
||||||
}
|
}
|
||||||
|
|
||||||
getBadgeCount() {
|
getBadgeCount(): ?number {
|
||||||
return this._badgeCount;
|
return this._badgeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
getData() {
|
getData(): ?Object {
|
||||||
return this._data;
|
return this._data;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,256 @@
|
|||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 46;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
148699CF1ABD045300480536 /* RCTPushNotificationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 148699CE1ABD045300480536 /* RCTPushNotificationManager.m */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
|
58B511D91A9E6C8500147676 /* CopyFiles */ = {
|
||||||
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
dstPath = "include/$(PRODUCT_NAME)";
|
||||||
|
dstSubfolderSpec = 16;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
134814201AA4EA6300B7C361 /* libRCTPushNotification.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTPushNotification.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
148699CD1ABD045300480536 /* RCTPushNotificationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPushNotificationManager.h; sourceTree = "<group>"; };
|
||||||
|
148699CE1ABD045300480536 /* RCTPushNotificationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTPushNotificationManager.m; sourceTree = "<group>"; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
58B511D81A9E6C8500147676 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
134814211AA4EA7D00B7C361 /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
134814201AA4EA6300B7C361 /* libRCTPushNotification.a */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
58B511D21A9E6C8500147676 = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
148699CD1ABD045300480536 /* RCTPushNotificationManager.h */,
|
||||||
|
148699CE1ABD045300480536 /* RCTPushNotificationManager.m */,
|
||||||
|
134814211AA4EA7D00B7C361 /* Products */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
58B511DA1A9E6C8500147676 /* RCTPushNotification */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTPushNotification" */;
|
||||||
|
buildPhases = (
|
||||||
|
58B511D71A9E6C8500147676 /* Sources */,
|
||||||
|
58B511D81A9E6C8500147676 /* Frameworks */,
|
||||||
|
58B511D91A9E6C8500147676 /* CopyFiles */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = RCTPushNotification;
|
||||||
|
productName = RCTDataManager;
|
||||||
|
productReference = 134814201AA4EA6300B7C361 /* libRCTPushNotification.a */;
|
||||||
|
productType = "com.apple.product-type.library.static";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
58B511D31A9E6C8500147676 /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
LastUpgradeCheck = 0610;
|
||||||
|
ORGANIZATIONNAME = Facebook;
|
||||||
|
TargetAttributes = {
|
||||||
|
58B511DA1A9E6C8500147676 = {
|
||||||
|
CreatedOnToolsVersion = 6.1.1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTPushNotification" */;
|
||||||
|
compatibilityVersion = "Xcode 3.2";
|
||||||
|
developmentRegion = English;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
);
|
||||||
|
mainGroup = 58B511D21A9E6C8500147676;
|
||||||
|
productRefGroup = 58B511D21A9E6C8500147676;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
58B511DA1A9E6C8500147676 /* RCTPushNotification */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
58B511D71A9E6C8500147676 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
148699CF1ABD045300480536 /* RCTPushNotificationManager.m in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
58B511ED1A9E6C8500147676 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
58B511EE1A9E6C8500147676 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = YES;
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
VALIDATE_PRODUCT = YES;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
58B511F01A9E6C8500147676 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
HEADER_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||||
|
"$(SRCROOT)/../../ReactKit/**",
|
||||||
|
);
|
||||||
|
LIBRARY_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"/Users/nicklockwood/fbobjc-hg/Libraries/FBReactKit/js/react-native-github/ReactKit/build/Debug-iphoneos",
|
||||||
|
);
|
||||||
|
OTHER_LDFLAGS = "-ObjC";
|
||||||
|
PRODUCT_NAME = RCTPushNotification;
|
||||||
|
SKIP_INSTALL = YES;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
58B511F11A9E6C8500147676 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
HEADER_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||||
|
"$(SRCROOT)/../../ReactKit/**",
|
||||||
|
);
|
||||||
|
LIBRARY_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"/Users/nicklockwood/fbobjc-hg/Libraries/FBReactKit/js/react-native-github/ReactKit/build/Debug-iphoneos",
|
||||||
|
);
|
||||||
|
OTHER_LDFLAGS = "-ObjC";
|
||||||
|
PRODUCT_NAME = RCTPushNotification;
|
||||||
|
SKIP_INSTALL = YES;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTPushNotification" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
58B511ED1A9E6C8500147676 /* Debug */,
|
||||||
|
58B511EE1A9E6C8500147676 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTPushNotification" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
58B511F01A9E6C8500147676 /* Debug */,
|
||||||
|
58B511F11A9E6C8500147676 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 58B511D31A9E6C8500147676 /* Project object */;
|
||||||
|
}
|
@ -7,13 +7,16 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <FBReactKit/RCTBridgeModule.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
extern NSString *const RKRemoteNotificationReceived;
|
#import "RCTBridgeModule.h"
|
||||||
extern NSString *const RKOpenURLNotification;
|
|
||||||
|
|
||||||
@interface RCTPushNotificationManager : NSObject <RCTBridgeModule>
|
@interface RCTPushNotificationManager : NSObject <RCTBridgeModule>
|
||||||
|
|
||||||
- (instancetype)initWithInitialNotification:(NSDictionary *)initialNotification NS_DESIGNATED_INITIALIZER;
|
- (instancetype)initWithInitialNotification:(NSDictionary *)initialNotification NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
+ (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;
|
||||||
|
+ (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification;
|
||||||
|
+ (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;
|
||||||
|
|
||||||
@end
|
@end
|
156
Libraries/PushNotificationIOS/RCTPushNotificationManager.m
Normal file
156
Libraries/PushNotificationIOS/RCTPushNotificationManager.m
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "RCTPushNotificationManager.h"
|
||||||
|
|
||||||
|
#import "RCTBridge.h"
|
||||||
|
#import "RCTEventDispatcher.h"
|
||||||
|
|
||||||
|
NSString *const RCTRemoteNotificationReceived = @"RemoteNotificationReceived";
|
||||||
|
NSString *const RCTOpenURLNotification = @"RCTOpenURLNotification";
|
||||||
|
|
||||||
|
@implementation RCTPushNotificationManager
|
||||||
|
{
|
||||||
|
NSDictionary *_initialNotification;
|
||||||
|
}
|
||||||
|
|
||||||
|
@synthesize bridge = _bridge;
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
return [self initWithInitialNotification:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithInitialNotification:(NSDictionary *)initialNotification
|
||||||
|
{
|
||||||
|
if ((self = [super init])) {
|
||||||
|
_initialNotification = [initialNotification copy];
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(handleRemoteNotificationReceived:)
|
||||||
|
name:RCTRemoteNotificationReceived
|
||||||
|
object:nil];
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(handleOpenURLNotification:)
|
||||||
|
name:RCTOpenURLNotification
|
||||||
|
object:nil];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
|
||||||
|
{
|
||||||
|
#ifdef __IPHONE_8_0
|
||||||
|
[application registerForRemoteNotifications];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification
|
||||||
|
{
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:RCTRemoteNotificationReceived
|
||||||
|
object:self
|
||||||
|
userInfo:notification];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (BOOL)application:(UIApplication *)application
|
||||||
|
openURL:(NSURL *)url
|
||||||
|
sourceApplication:(NSString *)sourceApplication
|
||||||
|
annotation:(id)annotation
|
||||||
|
{
|
||||||
|
NSDictionary *payload = @{@"url": [url absoluteString]};
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:RCTOpenURLNotification
|
||||||
|
object:self
|
||||||
|
userInfo:payload];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)handleRemoteNotificationReceived:(NSNotification *)notification
|
||||||
|
{
|
||||||
|
[_bridge.eventDispatcher sendDeviceEventWithName:@"remoteNotificationReceived"
|
||||||
|
body:[notification userInfo]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)handleOpenURLNotification:(NSNotification *)notification
|
||||||
|
{
|
||||||
|
[_bridge.eventDispatcher sendDeviceEventWithName:@"openURL"
|
||||||
|
body:[notification userInfo]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the application icon badge number on the home screen
|
||||||
|
*/
|
||||||
|
+ (void)setApplicationIconBadgeNumber:(NSInteger)number
|
||||||
|
{
|
||||||
|
RCT_EXPORT();
|
||||||
|
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
[self requestPermissions];
|
||||||
|
});
|
||||||
|
|
||||||
|
[UIApplication sharedApplication].applicationIconBadgeNumber = number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current application icon badge number on the home screen
|
||||||
|
*/
|
||||||
|
+ (void)getApplicationIconBadgeNumber:(RCTResponseSenderBlock)callback
|
||||||
|
{
|
||||||
|
RCT_EXPORT();
|
||||||
|
|
||||||
|
callback(@[
|
||||||
|
@([UIApplication sharedApplication].applicationIconBadgeNumber)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)requestPermissions
|
||||||
|
{
|
||||||
|
RCT_EXPORT();
|
||||||
|
|
||||||
|
#ifdef __IPHONE_8_0
|
||||||
|
UIUserNotificationType types = UIUserNotificationTypeSound | UIUserNotificationTypeBadge | UIUserNotificationTypeAlert;
|
||||||
|
UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
|
||||||
|
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
|
||||||
|
#else
|
||||||
|
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)checkPermissions:(RCTResponseSenderBlock)callback
|
||||||
|
{
|
||||||
|
RCT_EXPORT();
|
||||||
|
|
||||||
|
NSMutableDictionary *permissions = [[NSMutableDictionary alloc] init];
|
||||||
|
#ifdef __IPHONE_8_0
|
||||||
|
UIUserNotificationType types = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];
|
||||||
|
permissions[@"alert"] = @((BOOL)(types & UIUserNotificationTypeAlert));
|
||||||
|
permissions[@"badge"] = @((BOOL)(types & UIUserNotificationTypeBadge));
|
||||||
|
permissions[@"sound"] = @((BOOL)(types & UIUserNotificationTypeSound));
|
||||||
|
#else
|
||||||
|
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
|
||||||
|
permissions[@"alert"] = @((BOOL)(types & UIRemoteNotificationTypeAlert));
|
||||||
|
permissions[@"badge"] = @((BOOL)(types & UIRemoteNotificationTypeBadge));
|
||||||
|
permissions[@"sound"] = @((BOOL)(types & UIRemoteNotificationTypeSound));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
callback(@[permissions]);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *)constantsToExport
|
||||||
|
{
|
||||||
|
return @{
|
||||||
|
@"initialNotification": _initialNotification ?: [NSNull null]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -7,14 +7,15 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule TextStylePropTypes
|
* @providesModule TextStylePropTypes
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var ReactPropTypes = require('ReactPropTypes');
|
var ReactPropTypes = require('ReactPropTypes');
|
||||||
var ViewStylePropTypes = require('ViewStylePropTypes');
|
var ViewStylePropTypes = require('ViewStylePropTypes');
|
||||||
|
|
||||||
var TextStylePropTypes = {
|
// TODO: use spread instead of Object.assign/create after #6560135 is fixed
|
||||||
...ViewStylePropTypes,
|
var TextStylePropTypes = Object.assign(Object.create(ViewStylePropTypes), {
|
||||||
fontFamily: ReactPropTypes.string,
|
fontFamily: ReactPropTypes.string,
|
||||||
fontSize: ReactPropTypes.number,
|
fontSize: ReactPropTypes.number,
|
||||||
fontWeight: ReactPropTypes.oneOf(['normal' /*default*/, 'bold']),
|
fontWeight: ReactPropTypes.oneOf(['normal' /*default*/, 'bold']),
|
||||||
@ -28,7 +29,7 @@ var TextStylePropTypes = {
|
|||||||
writingDirection: ReactPropTypes.oneOf(
|
writingDirection: ReactPropTypes.oneOf(
|
||||||
['auto' /*default*/, 'ltr', 'rtl']
|
['auto' /*default*/, 'ltr', 'rtl']
|
||||||
),
|
),
|
||||||
};
|
});
|
||||||
|
|
||||||
// Text doesn't support padding correctly (#4841912)
|
// Text doesn't support padding correctly (#4841912)
|
||||||
var unsupportedProps = Object.keys({
|
var unsupportedProps = Object.keys({
|
||||||
@ -41,8 +42,8 @@ var unsupportedProps = Object.keys({
|
|||||||
paddingHorizontal: null,
|
paddingHorizontal: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
for (var key in unsupportedProps) {
|
for (var ii = 0; ii < unsupportedProps.length; ii++) {
|
||||||
delete TextStylePropTypes[key];
|
delete TextStylePropTypes[unsupportedProps[ii]];
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = TextStylePropTypes;
|
module.exports = TextStylePropTypes;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule Dimensions
|
* @providesModule Dimensions
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ class Dimensions {
|
|||||||
*
|
*
|
||||||
* @param {object} dims Simple string-keyed object of dimensions to set
|
* @param {object} dims Simple string-keyed object of dimensions to set
|
||||||
*/
|
*/
|
||||||
static set(dims) {
|
static set(dims: {[key:string]: any}): bool {
|
||||||
Object.assign(dimensions, dims);
|
Object.assign(dimensions, dims);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -40,7 +41,7 @@ class Dimensions {
|
|||||||
* @param {string} dim Name of dimension as defined when calling `set`.
|
* @param {string} dim Name of dimension as defined when calling `set`.
|
||||||
* @returns {Object?} Value for the dimension.
|
* @returns {Object?} Value for the dimension.
|
||||||
*/
|
*/
|
||||||
static get(dim) {
|
static get(dim: string): Object {
|
||||||
invariant(dimensions[dim], 'No dimension set for key ' + dim);
|
invariant(dimensions[dim], 'No dimension set for key ' + dim);
|
||||||
return dimensions[dim];
|
return dimensions[dim];
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule MessageQueue
|
* @providesModule MessageQueue
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
var ErrorUtils = require('ErrorUtils');
|
var ErrorUtils = require('ErrorUtils');
|
||||||
@ -18,6 +19,18 @@ var JSTimersExecution = require('JSTimersExecution');
|
|||||||
|
|
||||||
var INTERNAL_ERROR = 'Error in MessageQueue implementation';
|
var INTERNAL_ERROR = 'Error in MessageQueue implementation';
|
||||||
|
|
||||||
|
type ModulesConfig = {
|
||||||
|
[key:string]: {
|
||||||
|
moduleID: number;
|
||||||
|
methods: {[key:string]: {
|
||||||
|
methodID: number;
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type NameToID = {[key:string]: number}
|
||||||
|
type IDToName = {[key:number]: string}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* So as not to confuse static build system.
|
* So as not to confuse static build system.
|
||||||
*/
|
*/
|
||||||
@ -45,7 +58,11 @@ var jsCall = function(module, methodName, params) {
|
|||||||
* efficient numeric IDs.
|
* efficient numeric IDs.
|
||||||
* @class MessageQueue
|
* @class MessageQueue
|
||||||
*/
|
*/
|
||||||
var MessageQueue = function(remoteModulesConfig, localModulesConfig, customRequire) {
|
var MessageQueue = function(
|
||||||
|
remoteModulesConfig: ModulesConfig,
|
||||||
|
localModulesConfig: ModulesConfig,
|
||||||
|
customRequire: (id: string) => any
|
||||||
|
) {
|
||||||
this._requireFunc = customRequire || requireFunc;
|
this._requireFunc = customRequire || requireFunc;
|
||||||
this._initBookeeping();
|
this._initBookeeping();
|
||||||
this._initNamingMap(remoteModulesConfig, localModulesConfig);
|
this._initNamingMap(remoteModulesConfig, localModulesConfig);
|
||||||
@ -128,7 +145,10 @@ var MessageQueueMixin = {
|
|||||||
* @param {object} remoteModulesConfig Configuration of modules and their
|
* @param {object} remoteModulesConfig Configuration of modules and their
|
||||||
* methods.
|
* methods.
|
||||||
*/
|
*/
|
||||||
_initNamingMap: function(remoteModulesConfig, localModulesConfig) {
|
_initNamingMap: function(
|
||||||
|
remoteModulesConfig: ModulesConfig,
|
||||||
|
localModulesConfig: ModulesConfig
|
||||||
|
) {
|
||||||
this._remoteModuleNameToModuleID = {};
|
this._remoteModuleNameToModuleID = {};
|
||||||
this._remoteModuleIDToModuleName = {}; // Reverse
|
this._remoteModuleIDToModuleName = {}; // Reverse
|
||||||
|
|
||||||
@ -142,11 +162,11 @@ var MessageQueueMixin = {
|
|||||||
this._localModuleNameToMethodIDToName = {}; // Reverse
|
this._localModuleNameToMethodIDToName = {}; // Reverse
|
||||||
|
|
||||||
function fillMappings(
|
function fillMappings(
|
||||||
modulesConfig,
|
modulesConfig: ModulesConfig,
|
||||||
moduleNameToModuleID,
|
moduleNameToModuleID: NameToID,
|
||||||
moduleIDToModuleName,
|
moduleIDToModuleName: IDToName,
|
||||||
moduleNameToMethodNameToID,
|
moduleNameToMethodNameToID: {[key:string]: NameToID},
|
||||||
moduleNameToMethodIDToName
|
moduleNameToMethodIDToName: {[key:string]: IDToName}
|
||||||
) {
|
) {
|
||||||
for (var moduleName in modulesConfig) {
|
for (var moduleName in modulesConfig) {
|
||||||
var moduleConfig = modulesConfig[moduleName];
|
var moduleConfig = modulesConfig[moduleName];
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule PixelRatio
|
* @providesModule PixelRatio
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ class PixelRatio {
|
|||||||
* - PixelRatio.get() === 3
|
* - PixelRatio.get() === 3
|
||||||
* - iPhone 6 plus
|
* - iPhone 6 plus
|
||||||
*/
|
*/
|
||||||
static get() {
|
static get(): number {
|
||||||
return Dimensions.get('window').scale;
|
return Dimensions.get('window').scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule Platform
|
* @providesModule Platform
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule RCTLog
|
* @providesModule RCTLog
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
/* globals nativeLoggingHook */
|
/* globals nativeLoggingHook */
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -31,7 +32,7 @@ class RCTLog {
|
|||||||
logFn,
|
logFn,
|
||||||
'Level "' + level + '" not one of ' + Object.keys(levelsMap)
|
'Level "' + level + '" not one of ' + Object.keys(levelsMap)
|
||||||
);
|
);
|
||||||
if (typeof nativeLoggingHook === 'undefined') {
|
if (typeof global.nativeLoggingHook === 'undefined') {
|
||||||
// We already printed in xcode, so only log here if using a js debugger
|
// We already printed in xcode, so only log here if using a js debugger
|
||||||
console[logFn].apply(console, args);
|
console[logFn].apply(console, args);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule RCTRenderingPerf
|
* @providesModule RCTRenderingPerf
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -15,6 +16,11 @@ var ReactPerf = require('ReactPerf');
|
|||||||
|
|
||||||
var invariant = require('invariant');
|
var invariant = require('invariant');
|
||||||
|
|
||||||
|
type perfModule = {
|
||||||
|
start: () => void;
|
||||||
|
stop: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
var perfModules = [];
|
var perfModules = [];
|
||||||
var enabled = false;
|
var enabled = false;
|
||||||
|
|
||||||
@ -58,7 +64,7 @@ var RCTRenderingPerf = {
|
|||||||
perfModules.forEach((module) => module.stop());
|
perfModules.forEach((module) => module.stop());
|
||||||
},
|
},
|
||||||
|
|
||||||
register: function(module) {
|
register: function(module: perfModule) {
|
||||||
invariant(
|
invariant(
|
||||||
typeof module.start === 'function',
|
typeof module.start === 'function',
|
||||||
'Perf module should have start() function'
|
'Perf module should have start() function'
|
||||||
|
@ -7,9 +7,13 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule TimerMixin
|
* @providesModule TimerMixin
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var setImmediate = require('setImmediate');
|
||||||
|
var clearImmediate = require('clearImmediate');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Using bare setTimeout, setInterval, setImmediate and
|
* Using bare setTimeout, setInterval, setImmediate and
|
||||||
* requestAnimationFrame calls is very dangerous because if you forget to cancel
|
* requestAnimationFrame calls is very dangerous because if you forget to cancel
|
||||||
@ -35,7 +39,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var setter = function(setter, clearer, array) {
|
var setter = function(setter, clearer, array) {
|
||||||
return function(callback, delta) {
|
return function(
|
||||||
|
callback: () => void,
|
||||||
|
delta: number
|
||||||
|
): number {
|
||||||
var id = setter(() => {
|
var id = setter(() => {
|
||||||
clearer.call(this, id);
|
clearer.call(this, id);
|
||||||
callback.apply(this, arguments);
|
callback.apply(this, arguments);
|
||||||
@ -51,7 +58,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
var clearer = function(clearer, array) {
|
var clearer = function(clearer, array) {
|
||||||
return function(id) {
|
return function(id: number) {
|
||||||
if (this[array]) {
|
if (this[array]) {
|
||||||
var index = this[array].indexOf(id);
|
var index = this[array].indexOf(id);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
@ -75,8 +82,8 @@
|
|||||||
var _setImmediate = setter(setImmediate, _clearImmediate, _immediates);
|
var _setImmediate = setter(setImmediate, _clearImmediate, _immediates);
|
||||||
|
|
||||||
var _rafs = 'TimerMixin_rafs';
|
var _rafs = 'TimerMixin_rafs';
|
||||||
var _cancelAnimationFrame = clearer(cancelAnimationFrame, _rafs);
|
var _cancelAnimationFrame = clearer(window.cancelAnimationFrame, _rafs);
|
||||||
var _requestAnimationFrame = setter(requestAnimationFrame, _cancelAnimationFrame, _rafs);
|
var _requestAnimationFrame = setter(window.requestAnimationFrame, _cancelAnimationFrame, _rafs);
|
||||||
|
|
||||||
var TimerMixin = {
|
var TimerMixin = {
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule createStrictShapeTypeChecker
|
* @providesModule createStrictShapeTypeChecker
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -15,8 +16,10 @@ var ReactPropTypeLocationNames = require('ReactPropTypeLocationNames');
|
|||||||
var invariant = require('invariant');
|
var invariant = require('invariant');
|
||||||
var merge = require('merge');
|
var merge = require('merge');
|
||||||
|
|
||||||
function createStrictShapeTypeChecker(shapeTypes) {
|
function createStrictShapeTypeChecker(
|
||||||
function checkType(isRequired, props, propName, componentName, location) {
|
shapeTypes: {[key: string]: ReactPropsCheckType}
|
||||||
|
): ReactPropsChainableTypeChecker {
|
||||||
|
function checkType(isRequired, props, propName, componentName, location?) {
|
||||||
if (!props[propName]) {
|
if (!props[propName]) {
|
||||||
if (isRequired) {
|
if (isRequired) {
|
||||||
invariant(
|
invariant(
|
||||||
@ -29,7 +32,8 @@ function createStrictShapeTypeChecker(shapeTypes) {
|
|||||||
}
|
}
|
||||||
var propValue = props[propName];
|
var propValue = props[propName];
|
||||||
var propType = typeof propValue;
|
var propType = typeof propValue;
|
||||||
var locationName = ReactPropTypeLocationNames[location];
|
var locationName =
|
||||||
|
location && ReactPropTypeLocationNames[location] || '(unknown)';
|
||||||
if (propType !== 'object') {
|
if (propType !== 'object') {
|
||||||
invariant(
|
invariant(
|
||||||
false,
|
false,
|
||||||
@ -57,11 +61,17 @@ function createStrictShapeTypeChecker(shapeTypes) {
|
|||||||
error.message +
|
error.message +
|
||||||
`\nBad object: ` + JSON.stringify(props[propName], null, ' ')
|
`\nBad object: ` + JSON.stringify(props[propName], null, ' ')
|
||||||
);
|
);
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var chainedCheckType = checkType.bind(null, false);
|
function chainedCheckType(
|
||||||
|
props: {[key: string]: any},
|
||||||
|
propName: string,
|
||||||
|
componentName: string,
|
||||||
|
location?: string
|
||||||
|
): ?Error {
|
||||||
|
return checkType(false, props, propName, componentName, location);
|
||||||
|
}
|
||||||
chainedCheckType.isRequired = checkType.bind(null, true);
|
chainedCheckType.isRequired = checkType.bind(null, true);
|
||||||
return chainedCheckType;
|
return chainedCheckType;
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,11 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule deepFreezeAndThrowOnMutationInDev
|
* @providesModule deepFreezeAndThrowOnMutationInDev
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If your application is accepting different values for the same field over
|
* If your application is accepting different values for the same field over
|
||||||
* time and is doing a diff on them, you can either (1) create a copy or
|
* time and is doing a diff on them, you can either (1) create a copy or
|
||||||
@ -26,7 +29,7 @@
|
|||||||
* Freezing the object and adding the throw mechanism is expensive and will
|
* Freezing the object and adding the throw mechanism is expensive and will
|
||||||
* only be used in DEV.
|
* only be used in DEV.
|
||||||
*/
|
*/
|
||||||
function deepFreezeAndThrowOnMutationInDev(object) {
|
function deepFreezeAndThrowOnMutationInDev(object: Object) {
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
if (typeof object !== 'object' ||
|
if (typeof object !== 'object' ||
|
||||||
object === null ||
|
object === null ||
|
||||||
|
@ -7,9 +7,17 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule insetsDiffer
|
* @providesModule insetsDiffer
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
type Inset = {
|
||||||
|
top: ?number;
|
||||||
|
left: ?number;
|
||||||
|
right: ?number;
|
||||||
|
bottom: ?number;
|
||||||
|
}
|
||||||
|
|
||||||
var dummyInsets = {
|
var dummyInsets = {
|
||||||
top: undefined,
|
top: undefined,
|
||||||
left: undefined,
|
left: undefined,
|
||||||
@ -17,7 +25,10 @@ var dummyInsets = {
|
|||||||
bottom: undefined,
|
bottom: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
var insetsDiffer = function(one, two) {
|
var insetsDiffer = function(
|
||||||
|
one: ?Inset,
|
||||||
|
two: ?Inset
|
||||||
|
): bool {
|
||||||
one = one || dummyInsets;
|
one = one || dummyInsets;
|
||||||
two = two || dummyInsets;
|
two = two || dummyInsets;
|
||||||
return one !== two && (
|
return one !== two && (
|
||||||
|
@ -7,12 +7,18 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule pointsDiffer
|
* @providesModule pointsDiffer
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
type Point = {
|
||||||
|
x: ?number;
|
||||||
|
y: ?number;
|
||||||
|
}
|
||||||
|
|
||||||
var dummyPoint = {x: undefined, y: undefined};
|
var dummyPoint = {x: undefined, y: undefined};
|
||||||
|
|
||||||
var pointsDiffer = function(one, two) {
|
var pointsDiffer = function(one: ?Point, two: ?Point): bool {
|
||||||
one = one || dummyPoint;
|
one = one || dummyPoint;
|
||||||
two = two || dummyPoint;
|
two = two || dummyPoint;
|
||||||
return one !== two && (
|
return one !== two && (
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule groupByEveryN
|
* @providesModule groupByEveryN
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,7 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function groupByEveryN(array, n) {
|
function groupByEveryN<T>(array: Array<T>, n: number): Array<Array<?T>> {
|
||||||
var result = [];
|
var result = [];
|
||||||
var temp = [];
|
var temp = [];
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule logError
|
* @providesModule logError
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule mergeFast
|
* @providesModule mergeFast
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -19,7 +20,7 @@
|
|||||||
* @return {object} Merging of two objects, including prototype
|
* @return {object} Merging of two objects, including prototype
|
||||||
* inherited properties.
|
* inherited properties.
|
||||||
*/
|
*/
|
||||||
var mergeFast = function(one, two) {
|
var mergeFast = function(one: Object, two: Object): Object {
|
||||||
var ret = {};
|
var ret = {};
|
||||||
for (var keyOne in one) {
|
for (var keyOne in one) {
|
||||||
ret[keyOne] = one[keyOne];
|
ret[keyOne] = one[keyOne];
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule mergeIntoFast
|
* @providesModule mergeIntoFast
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -17,7 +18,7 @@
|
|||||||
* @param {object} one Object to assign to.
|
* @param {object} one Object to assign to.
|
||||||
* @param {object} two Object to assign from.
|
* @param {object} two Object to assign from.
|
||||||
*/
|
*/
|
||||||
var mergeIntoFast = function(one, two) {
|
var mergeIntoFast = function(one: Object, two: Object): void {
|
||||||
for (var keyTwo in two) {
|
for (var keyTwo in two) {
|
||||||
one[keyTwo] = two[keyTwo];
|
one[keyTwo] = two[keyTwo];
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,14 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule nativeModulePrefixNormalizer
|
* @providesModule nativeModulePrefixNormalizer
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Dirty hack to support old (RK) and new (RCT) native module name conventions
|
// Dirty hack to support old (RK) and new (RCT) native module name conventions
|
||||||
function nativeModulePrefixNormalizer(modules) {
|
function nativeModulePrefixNormalizer(
|
||||||
|
modules: {[key: string]: any}
|
||||||
|
): void {
|
||||||
Object.keys(modules).forEach((moduleName) => {
|
Object.keys(modules).forEach((moduleName) => {
|
||||||
var strippedName = moduleName.replace(/^(RCT|RK)/, '');
|
var strippedName = moduleName.replace(/^(RCT|RK)/, '');
|
||||||
if (modules['RCT' + strippedName] && modules['RK' + strippedName]) {
|
if (modules['RCT' + strippedName] && modules['RK' + strippedName]) {
|
||||||
|
@ -7,11 +7,18 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule truncate
|
* @providesModule truncate
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var merge = require('merge');
|
var merge = require('merge');
|
||||||
|
|
||||||
|
type truncateOptions = {
|
||||||
|
breakOnWords: boolean;
|
||||||
|
minDelta: number;
|
||||||
|
elipsis: string;
|
||||||
|
}
|
||||||
|
|
||||||
var defaultOptions = {
|
var defaultOptions = {
|
||||||
breakOnWords: true,
|
breakOnWords: true,
|
||||||
minDelta: 10, // Prevents truncating a tiny bit off the end
|
minDelta: 10, // Prevents truncating a tiny bit off the end
|
||||||
@ -19,7 +26,11 @@ var defaultOptions = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// maxChars (including elipsis)
|
// maxChars (including elipsis)
|
||||||
var truncate = function(str, maxChars, options) {
|
var truncate = function(
|
||||||
|
str: ?string,
|
||||||
|
maxChars: number,
|
||||||
|
options: truncateOptions
|
||||||
|
): ?string {
|
||||||
options = merge(defaultOptions, options);
|
options = merge(defaultOptions, options);
|
||||||
if (str && str.length &&
|
if (str && str.length &&
|
||||||
str.length - options.minDelta + options.elipsis.length >= maxChars) {
|
str.length - options.minDelta + options.elipsis.length >= maxChars) {
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule VibrationIOS
|
* @providesModule VibrationIOS
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
2
Libraries/react-native/react-native.js
vendored
2
Libraries/react-native/react-native.js
vendored
@ -42,7 +42,6 @@ var ReactNative = Object.assign(Object.create(require('React')), {
|
|||||||
AlertIOS: require('AlertIOS'),
|
AlertIOS: require('AlertIOS'),
|
||||||
Animation: require('Animation'),
|
Animation: require('Animation'),
|
||||||
AppRegistry: require('AppRegistry'),
|
AppRegistry: require('AppRegistry'),
|
||||||
AppState: require('AppState'),
|
|
||||||
AppStateIOS: require('AppStateIOS'),
|
AppStateIOS: require('AppStateIOS'),
|
||||||
AsyncStorage: require('AsyncStorage'),
|
AsyncStorage: require('AsyncStorage'),
|
||||||
CameraRoll: require('CameraRoll'),
|
CameraRoll: require('CameraRoll'),
|
||||||
@ -50,6 +49,7 @@ var ReactNative = Object.assign(Object.create(require('React')), {
|
|||||||
LayoutAnimation: require('LayoutAnimation'),
|
LayoutAnimation: require('LayoutAnimation'),
|
||||||
NetInfo: require('NetInfo'),
|
NetInfo: require('NetInfo'),
|
||||||
PixelRatio: require('PixelRatio'),
|
PixelRatio: require('PixelRatio'),
|
||||||
|
PushNotificationIOS: require('PushNotificationIOS'),
|
||||||
StatusBarIOS: require('StatusBarIOS'),
|
StatusBarIOS: require('StatusBarIOS'),
|
||||||
StyleSheet: require('StyleSheet'),
|
StyleSheet: require('StyleSheet'),
|
||||||
TimerMixin: require('TimerMixin'),
|
TimerMixin: require('TimerMixin'),
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
#import <QuartzCore/QuartzCore.h>
|
#import <QuartzCore/QuartzCore.h>
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
#import "../Layout/Layout.h"
|
#import "Layout.h"
|
||||||
#import "../Views/RCTAnimationType.h"
|
#import "RCTAnimationType.h"
|
||||||
#import "../Views/RCTPointerEvents.h"
|
#import "RCTPointerEvents.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides a collection of conversion functions for mapping
|
* This class provides a collection of conversion functions for mapping
|
||||||
|
@ -87,26 +87,4 @@ static NSString *RCTCurrentAppBackgroundState()
|
|||||||
callback(@[@{@"app_state": _lastKnownState}]);
|
callback(@[@{@"app_state": _lastKnownState}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the application icon badge number on the home screen
|
|
||||||
*/
|
|
||||||
- (void)setApplicationIconBadgeNumber:(NSInteger)number
|
|
||||||
{
|
|
||||||
RCT_EXPORT();
|
|
||||||
|
|
||||||
[UIApplication sharedApplication].applicationIconBadgeNumber = number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current application icon badge number on the home screen
|
|
||||||
*/
|
|
||||||
- (void)getApplicationIconBadgeNumber:(RCTResponseSenderBlock)callback
|
|
||||||
{
|
|
||||||
RCT_EXPORT();
|
|
||||||
|
|
||||||
callback(@[
|
|
||||||
@([UIApplication sharedApplication].applicationIconBadgeNumber)
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import "RCTPushNotificationManager.h"
|
|
||||||
|
|
||||||
#import "RCTAssert.h"
|
|
||||||
#import "RCTBridge.h"
|
|
||||||
#import "RCTEventDispatcher.h"
|
|
||||||
|
|
||||||
NSString *const RKRemoteNotificationReceived = @"RemoteNotificationReceived";
|
|
||||||
NSString *const RKOpenURLNotification = @"RKOpenURLNotification";
|
|
||||||
|
|
||||||
@implementation RCTPushNotificationManager
|
|
||||||
{
|
|
||||||
NSDictionary *_initialNotification;
|
|
||||||
}
|
|
||||||
|
|
||||||
@synthesize bridge = _bridge;
|
|
||||||
|
|
||||||
- (instancetype)init
|
|
||||||
{
|
|
||||||
return [self initWithInitialNotification:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (instancetype)initWithInitialNotification:(NSDictionary *)initialNotification
|
|
||||||
{
|
|
||||||
if ((self = [super init])) {
|
|
||||||
_initialNotification = [initialNotification copy];
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
||||||
selector:@selector(handleRemoteNotificationReceived:)
|
|
||||||
name:RKRemoteNotificationReceived
|
|
||||||
object:nil];
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
||||||
selector:@selector(handleOpenURLNotification:)
|
|
||||||
name:RKOpenURLNotification
|
|
||||||
object:nil];
|
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)handleRemoteNotificationReceived:(NSNotification *)notification
|
|
||||||
{
|
|
||||||
[_bridge.eventDispatcher sendDeviceEventWithName:@"remoteNotificationReceived"
|
|
||||||
body:[notification userInfo]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)handleOpenURLNotification:(NSNotification *)notification
|
|
||||||
{
|
|
||||||
[_bridge.eventDispatcher sendDeviceEventWithName:@"openURL"
|
|
||||||
body:[notification userInfo]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSDictionary *)constantsToExport
|
|
||||||
{
|
|
||||||
return @{
|
|
||||||
@"initialNotification": _initialNotification ?: [NSNull null]
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)dealloc
|
|
||||||
{
|
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
@ -9,8 +9,7 @@
|
|||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
#import "../Layout/Layout.h"
|
#import "Layout.h"
|
||||||
|
|
||||||
#import "RCTViewNodeProtocol.h"
|
#import "RCTViewNodeProtocol.h"
|
||||||
|
|
||||||
@class RCTSparseArray;
|
@class RCTSparseArray;
|
||||||
|
@ -166,6 +166,69 @@ describe('DependencyGraph', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pit('should default main package to index.js', function() {
|
||||||
|
var root = '/root';
|
||||||
|
fs.__setMockFilesystem({
|
||||||
|
'root': {
|
||||||
|
'index.js': 'require("aPackage")',
|
||||||
|
'aPackage': {
|
||||||
|
'package.json': JSON.stringify({
|
||||||
|
name: 'aPackage',
|
||||||
|
}),
|
||||||
|
'index.js': 'lol',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var dgraph = new DependencyGraph({
|
||||||
|
roots: [root],
|
||||||
|
fileWatcher: fileWatcher
|
||||||
|
});
|
||||||
|
return dgraph.load().then(function() {
|
||||||
|
expect(dgraph.getOrderedDependencies('/root/index.js'))
|
||||||
|
.toEqual([
|
||||||
|
{id: '/root/index.js', path: '/root/index.js', dependencies: ['aPackage']},
|
||||||
|
{ id: 'aPackage/index',
|
||||||
|
path: '/root/aPackage/index.js',
|
||||||
|
dependencies: []
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
pit('should default use index.js if main is a dir', function() {
|
||||||
|
var root = '/root';
|
||||||
|
fs.__setMockFilesystem({
|
||||||
|
'root': {
|
||||||
|
'index.js': 'require("aPackage")',
|
||||||
|
'aPackage': {
|
||||||
|
'package.json': JSON.stringify({
|
||||||
|
name: 'aPackage',
|
||||||
|
main: 'lib',
|
||||||
|
}),
|
||||||
|
lib: {
|
||||||
|
'index.js': 'lol',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var dgraph = new DependencyGraph({
|
||||||
|
roots: [root],
|
||||||
|
fileWatcher: fileWatcher
|
||||||
|
});
|
||||||
|
return dgraph.load().then(function() {
|
||||||
|
expect(dgraph.getOrderedDependencies('/root/index.js'))
|
||||||
|
.toEqual([
|
||||||
|
{id: '/root/index.js', path: '/root/index.js', dependencies: ['aPackage']},
|
||||||
|
{ id: 'aPackage/lib/index',
|
||||||
|
path: '/root/aPackage/lib/index.js',
|
||||||
|
dependencies: []
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
pit('should ignore malformed packages', function() {
|
pit('should ignore malformed packages', function() {
|
||||||
var root = '/root';
|
var root = '/root';
|
||||||
fs.__setMockFilesystem({
|
fs.__setMockFilesystem({
|
||||||
|
@ -184,6 +184,12 @@ DependecyGraph.prototype.resolveDependency = function(
|
|||||||
var main = packageJson.main || 'index';
|
var main = packageJson.main || 'index';
|
||||||
modulePath = withExtJs(path.join(packageJson._root, main));
|
modulePath = withExtJs(path.join(packageJson._root, main));
|
||||||
dep = this._graph[modulePath];
|
dep = this._graph[modulePath];
|
||||||
|
|
||||||
|
// Some packages use just a dir and rely on an index.js inside that dir.
|
||||||
|
if (dep == null) {
|
||||||
|
dep = this._graph[path.join(packageJson._root, main, 'index.js')];
|
||||||
|
}
|
||||||
|
|
||||||
if (dep == null) {
|
if (dep == null) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Cannot find package main file for package: ' + packageJson._root
|
'Cannot find package main file for package: ' + packageJson._root
|
||||||
|
@ -196,7 +196,7 @@
|
|||||||
if (!module) {
|
if (!module) {
|
||||||
msg = 'Requiring unknown module "' + id + '"';
|
msg = 'Requiring unknown module "' + id + '"';
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
msg += '. It may not be loaded yet. Did you forget to run arc build?';
|
msg += '. If you are sure the module is there, try restarting the packager.';
|
||||||
}
|
}
|
||||||
throw new ModuleError(msg);
|
throw new ModuleError(msg);
|
||||||
}
|
}
|
||||||
|
@ -186,6 +186,7 @@ describe('processRequest', function() {
|
|||||||
expect(packageFunc.mock.calls.length).toBe(1);
|
expect(packageFunc.mock.calls.length).toBe(1);
|
||||||
triggerFileChange('all','path/file.js', options.projectRoots[0]);
|
triggerFileChange('all','path/file.js', options.projectRoots[0]);
|
||||||
jest.runAllTimers();
|
jest.runAllTimers();
|
||||||
|
jest.runAllTimers();
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
expect(packageFunc.mock.calls.length).toBe(2);
|
expect(packageFunc.mock.calls.length).toBe(2);
|
||||||
|
7
packager/react-packager/src/Server/index.js
vendored
7
packager/react-packager/src/Server/index.js
vendored
@ -92,8 +92,10 @@ Server.prototype._rebuildPackages = function() {
|
|||||||
Object.keys(packages).forEach(function(key) {
|
Object.keys(packages).forEach(function(key) {
|
||||||
var options = getOptionsFromUrl(key);
|
var options = getOptionsFromUrl(key);
|
||||||
// Wait for a previous build (if exists) to finish.
|
// Wait for a previous build (if exists) to finish.
|
||||||
packages[key] = (packages[key] || q()).then(function() {
|
packages[key] = (packages[key] || q()).finally(function() {
|
||||||
return buildPackage(options).then(function(p) {
|
// With finally promise callback we can't change the state of the promise
|
||||||
|
// so we need to reassign the promise.
|
||||||
|
packages[key] = buildPackage(options).then(function(p) {
|
||||||
// Make a throwaway call to getSource to cache the source string.
|
// Make a throwaway call to getSource to cache the source string.
|
||||||
p.getSource({
|
p.getSource({
|
||||||
inlineSourceMap: options.dev,
|
inlineSourceMap: options.dev,
|
||||||
@ -102,6 +104,7 @@ Server.prototype._rebuildPackages = function() {
|
|||||||
return p;
|
return p;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
return packages[key];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user