@@ -50,10 +50,20 @@ + (id)allocWithZone:(NSZone *)zone {
5050
5151- (id )init {
5252 self = [super init ];
53-
5453 NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter ];
5554
5655 [defaultCenter removeObserver: self ];
56+
57+
58+ [defaultCenter addObserver: self
59+ selector: @selector (networkConnecting: )
60+ name: kJPFNetworkIsConnectingNotification
61+ object: nil ];
62+
63+ [defaultCenter addObserver: self
64+ selector: @selector (networkRegister: )
65+ name: kJPFNetworkDidRegisterNotification
66+ object: nil ];
5767
5868 [defaultCenter addObserver: self
5969 selector: @selector (networkDidSetup: )
@@ -110,6 +120,12 @@ - (void)reactJSDidload {
110120 [[NSNotificationCenter defaultCenter ] postNotificationName: kJPFOpenNotificationToLaunchApp object: [RCTJPushActionQueue sharedInstance ].openedLocalNotification];
111121 }
112122
123+ if (_isJPushDidLogin) {
124+ [[NSNotificationCenter defaultCenter ] postNotificationName: kJPFNetworkDidLoginNotification object: nil ];
125+ } else {
126+ [[NSNotificationCenter defaultCenter ] postNotificationName: kJPFNetworkDidCloseNotification object: nil ];
127+ }
128+
113129}
114130
115131- (void )setBridge : (RCTBridge *)bridge {
@@ -144,22 +160,40 @@ - (void)openNotification:(NSNotification *)notification {
144160 [self .bridge.eventDispatcher sendAppEventWithName: @" openNotification" body: obj];
145161}
146162
163+
164+ - (void )networkConnecting : (NSNotification *)notification {
165+ _isJPushDidLogin = false ;
166+ [self .bridge.eventDispatcher sendAppEventWithName: @" connectionChange"
167+ body: @(false )];
168+ }
169+
170+ - (void )networkRegister : (NSNotification *)notification {
171+ _isJPushDidLogin = false ;
172+ [self .bridge.eventDispatcher sendAppEventWithName: @" connectionChange"
173+ body: @(false )];
174+ }
175+
147176- (void )networkDidSetup : (NSNotification *)notification {
177+ _isJPushDidLogin = false ;
148178 [self .bridge.eventDispatcher sendAppEventWithName: @" connectionChange"
149179 body: @(true )];
150180}
151181
152182- (void )networkDidClose : (NSNotification *)notification {
183+ _isJPushDidLogin = false ;
153184 [self .bridge.eventDispatcher sendAppEventWithName: @" connectionChange"
154- body: @(true )];
185+ body: @(false )];
155186}
156187
157188
158189- (void )networkDidLogin : (NSNotification *)notification {
159190 _isJPushDidLogin = YES ;
160191 [[RCTJPushActionQueue sharedInstance ] scheduleGetRidCallbacks ];
192+ // [self.bridge.eventDispatcher sendAppEventWithName:@"connectionChange"
193+ // body:@(true)];
161194 [self .bridge.eventDispatcher sendAppEventWithName: @" networkDidLogin"
162195 body: nil ];
196+
163197}
164198
165199- (void )networkDidReceiveMessage : (NSNotification *)notification {
0 commit comments