-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
TiApp.h
205 lines (151 loc) · 4.96 KB
/
TiApp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
#import <UIKit/UIKit.h>
#import "TiHost.h"
#import "KrollBridge.h"
#ifdef USE_TI_UIWEBVIEW
#import "XHRBridge.h"
#endif
#import "TiRootViewController.h"
#import <TiCore/TiContextRef.h>
extern BOOL applicationInMemoryPanic;
TI_INLINE void waitForMemoryPanicCleared() //WARNING: This must never be run on main thread, or else there is a risk of deadlock!
{
while (applicationInMemoryPanic) {
[NSThread sleepForTimeInterval:0.01];
}
}
/**
TiApp represents an instance of an application. There is always only one instance per application which could be accessed through <app> class method.
@see app
*/
@interface TiApp : TiHost <UIApplicationDelegate>
{
UIWindow *window;
UIImageView *loadView;
UIImageView *splashScreenImage;
BOOL loaded;
TiContextGroupRef contextGroup;
KrollBridge *kjsBridge;
#ifdef USE_TI_UIWEBVIEW
XHRBridge *xhrBridge;
#endif
NSMutableDictionary *launchOptions;
NSTimeInterval started;
int32_t networkActivityCount;
TiRootViewController *controller;
NSString *userAgent;
NSString *remoteDeviceUUID;
id remoteNotificationDelegate;
NSDictionary* remoteNotification;
NSString *sessionId;
UIBackgroundTaskIdentifier bgTask;
NSMutableArray *backgroundServices;
NSMutableArray *runningServices;
NSDictionary *localNotification;
}
@property (nonatomic) BOOL forceSplashAsSnapshot;
/**
Returns application's primary window.
Convenience method to access the application's primary window
*/
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, assign) id remoteNotificationDelegate;
/**
Returns details for the last remote notification.
Dictionary containing details about remote notification, or _nil_.
*/
@property (nonatomic, readonly) NSDictionary* remoteNotification;
/**
Returns local notification that has bees sent on the application.
@return Dictionary containing details about local notification, or _nil_.
*/
@property (nonatomic, readonly) NSDictionary* localNotification;
/**
Returns the application's root view controller.
*/
@property (nonatomic, retain) TiRootViewController* controller;
@property (nonatomic, readonly) TiContextGroupRef contextGroup;
/**
Returns singleton instance of TiApp application object.
*/
+(TiApp*)app;
/**
* Returns a read-only dictionary from tiapp.xml properties
*/
+(NSDictionary *)tiAppProperties;
/*
Convenience method to returns root view controller for TiApp instance.
@return The application's root view controller.
@see controller
*/
+(TiRootViewController*)controller;
+(TiContextGroupRef)contextGroup;
-(BOOL)windowIsKeyWindow;
-(UIView *) topMostView;
-(void)attachXHRBridgeIfRequired;
/**
Returns application launch options
The method provides access to application launch options that became available when application just launched.
@return The launch options dictionary.
*/
-(NSDictionary*)launchOptions;
/**
Returns remote UUID for the current running device.
@return Current device UUID.
*/
-(NSString*)remoteDeviceUUID;
/**
Tells application to show network activity indicator.
Every call of startNetwork should be paired with <stopNetwork>.
@see stopNetwork
*/
-(void)startNetwork;
/**
Tells application to hide network activity indicator.
Every call of stopNetwork should have corresponding <startNetwork> call.
@see startNetwork
*/
-(void)stopNetwork;
/**
Prevents network activity indicator from showing.
Setting this property to YES disables appearance of network activity indicator when startNetwork is called.
In case network activity indicator is currently visible, it will be hidden.
@see startNetwork
@see stopNetwork
*/
@property (nonatomic, assign) BOOL disableNetworkActivityIndicator;
-(void)showModalError:(NSString*)message;
/**
Tells application to display modal view controller.
@param controller The view controller to display.
@param animated If _YES_, animates the view controller as it’s presented; otherwise, does not.
*/
-(void)showModalController:(UIViewController*)controller animated:(BOOL)animated;
/**
Tells application to hide modal view controller.
@param controller The view controller to hide.
@param animated If _YES_, animates the view controller as it’s hidden; otherwise, does not.
*/
-(void)hideModalController:(UIViewController*)controller animated:(BOOL)animated;
/**
Returns user agent string to use for network requests.
@return User agent string
*/
-(NSString*)userAgent;
/**
Returns unique identifier for the current application launch.
@return Current session id.
*/
-(NSString*)sessionId;
-(KrollBridge*)krollBridge;
-(void)beginBackgrounding;
-(void)endBackgrounding;
-(void)registerBackgroundService:(TiProxy*)proxy;
-(void)unregisterBackgroundService:(TiProxy*)proxy;
-(void)stopBackgroundService:(TiProxy*)proxy;
@end