[ReactNative] Put launchOptions in RCTPushNotificationManager

This commit is contained in:
Andrew Rasmussen
2015-03-16 12:33:02 -07:00
parent 06125009dd
commit 5f538b2284
4 changed files with 90 additions and 4 deletions

View File

@@ -15,12 +15,10 @@ function renderApplication(RootComponent, initialProps, rootTag) {
rootTag,
'Expect to have a valid rootTag, instead got ', rootTag
);
var pushNotification = initialProps.launchOptions &&
initialProps.launchOptions.remoteNotification &&
new PushNotificationIOS(initialProps.launchOptions.remoteNotification);
var initialNotification = PushNotificationIOS.popInitialNotification();
React.render(
<RootComponent
pushNotification={pushNotification}
pushNotification={initialNotification}
{...initialProps}
/>,
rootTag

View File

@@ -5,8 +5,12 @@
*/
'use strict';
var NativeModules = require('NativeModules');
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
var RCTPushNotificationManager = NativeModules.RCTPushNotificationManager;
var _initialNotification = RCTPushNotificationManager.initialNotification;
var _notifHandlers = {};
var DEVICE_NOTIF_EVENT = 'remoteNotificationReceived';
@@ -30,6 +34,14 @@ class PushNotificationIOS {
_notifHandlers[handler] = null;
}
static popInitialNotification() {
var initialNotification = _initialNotification &&
new PushNotificationIOS(_initialNotification);
_initialNotification = null;
return initialNotification;
}
constructor(nativeNotif) {
this._data = {};