Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 338a4e1

Browse files
committed
format
1 parent f90e9a9 commit 338a4e1

File tree

2 files changed

+89
-73
lines changed

2 files changed

+89
-73
lines changed

shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ - (void)userNotificationCenter:(UNUserNotificationCenter*)center
134134
}
135135
}
136136

137-
- (void)openURL:(NSURL *)url
138-
options:(NSDictionary<UIApplicationOpenExternalURLOptionsKey, id> *)options
139-
completionHandler:(void (^)(BOOL success))completion{
137+
- (void)openURL:(NSURL*)url
138+
options:(NSDictionary<UIApplicationOpenExternalURLOptionsKey, id>*)options
139+
completionHandler:(void (^)(BOOL success))completion {
140140
NSNumber* isDeepLinkingEnabled =
141141
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"];
142142
if (!isDeepLinkingEnabled.boolValue) {
@@ -151,22 +151,24 @@ - (void)openURL:(NSURL *)url
151151
if (didTimeout) {
152152
FML_LOG(ERROR)
153153
<< "Timeout waiting for the first frame when launching an URL.";
154-
completion(NO);
154+
completion(NO);
155155
} else {
156-
// invove the method and get the result
157-
[flutterViewController.engine.navigationChannel
158-
invokeMethod:@"pushRouteInformation"
159-
arguments:@{
160-
@"location" : url.absoluteString ?: [NSNull null],
161-
}
162-
result:^(id _Nullable result) {
163-
BOOL success = [result isKindOfClass:[NSNumber class]] && [result boolValue];
164-
if (!success) {
165-
// Logging the error if the result is not successful
166-
FML_LOG(ERROR) << "Failed to handle route information in Flutter.";
167-
}
168-
completion(success);
169-
}];
156+
// invove the method and get the result
157+
[flutterViewController.engine.navigationChannel
158+
invokeMethod:@"pushRouteInformation"
159+
arguments:@{
160+
@"location" : url.absoluteString ?: [NSNull null],
161+
}
162+
result:^(id _Nullable result) {
163+
BOOL success = [result isKindOfClass:[NSNumber class]] &&
164+
[result boolValue];
165+
if (!success) {
166+
// Logging the error if the result is not successful
167+
FML_LOG(ERROR)
168+
<< "Failed to handle route information in Flutter.";
169+
}
170+
completion(success);
171+
}];
170172
}
171173
}];
172174
} else {
@@ -177,16 +179,18 @@ - (void)openURL:(NSURL *)url
177179
}
178180

179181
- (BOOL)application:(UIApplication*)application
180-
openURL:(NSURL*)url
181-
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options
182-
completionHandler:(void (^)(BOOL success))completion {
182+
openURL:(NSURL*)url
183+
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options
184+
completionHandler:(void (^)(BOOL success))completion {
183185
if ([_lifeCycleDelegate application:application openURL:url options:options]) {
184-
completion(YES);
185-
} else {
186-
[self openURL:url options:options completionHandler:^(BOOL success) {
187-
completion(success);
186+
completion(YES);
187+
} else {
188+
[self openURL:url
189+
options:options
190+
completionHandler:^(BOOL success) {
191+
completion(success);
188192
}];
189-
}
193+
}
190194
}
191195

192196
- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url {
@@ -224,16 +228,18 @@ - (BOOL)application:(UIApplication*)application
224228
restorationHandler:
225229
(void (^)(NSArray<id<UIUserActivityRestoring>>* __nullable restorableObjects))
226230
restorationHandler
227-
completionHandler:(void (^)(BOOL success))completion {
231+
completionHandler:(void (^)(BOOL success))completion {
228232
if ([_lifeCycleDelegate application:application
229233
continueUserActivity:userActivity
230234
restorationHandler:restorationHandler]) {
231-
completion(YES);
235+
completion(YES);
232236
}
233237

234-
[self openURL:userActivity.webpageURL options:@{} completionHandler:^(BOOL success) {
235-
completion(success);
236-
}];
238+
[self openURL:userActivity.webpageURL
239+
options:@{}
240+
completionHandler:^(BOOL success) {
241+
completion(success);
242+
}];
237243
}
238244

239245
#pragma mark - FlutterPluginRegistry methods. All delegating to the rootViewController

shell/platform/darwin/ios/framework/Source/FlutterAppDelegateTest.mm

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,17 @@ - (void)testLaunchUrl {
6262
OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
6363
.andReturn(@YES);
6464

65-
OCMStub([self.mockNavigationChannel invokeMethod:@"pushRouteInformation"
66-
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}]).andReturn(@YES);
65+
OCMStub([self.mockNavigationChannel
66+
invokeMethod:@"pushRouteInformation"
67+
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}])
68+
.andReturn(@YES);
6769

6870
[self.appDelegate application:[UIApplication sharedApplication]
69-
openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
70-
options:@{}
71-
completionHandler:^(BOOL success) {
72-
XCTAssertTrue(success);
73-
}];
71+
openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
72+
options:@{}
73+
completionHandler:^(BOOL success) {
74+
XCTAssertTrue(success);
75+
}];
7476

7577
OCMVerifyAll(self.mockNavigationChannel);
7678
}
@@ -79,27 +81,29 @@ - (void)testLaunchUrlWithNavigationChannelReturningFalse {
7981
OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
8082
.andReturn(@YES);
8183

82-
OCMStub([self.mockNavigationChannel invokeMethod:@"pushRouteInformation"
83-
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}]).andReturn(@NO);
84+
OCMStub([self.mockNavigationChannel
85+
invokeMethod:@"pushRouteInformation"
86+
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}])
87+
.andReturn(@NO);
8488

8589
[self.appDelegate application:[UIApplication sharedApplication]
86-
openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
87-
options:@{}
88-
completionHandler:^(BOOL success) {
89-
XCTAssertFalse(success);
90-
}];
90+
openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
91+
options:@{}
92+
completionHandler:^(BOOL success) {
93+
XCTAssertFalse(success);
94+
}];
9195
}
9296

9397
- (void)testLaunchUrlWithDeepLinkingNotSet {
9498
OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
9599
.andReturn(nil);
96100

97101
[self.appDelegate application:[UIApplication sharedApplication]
98-
openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
99-
options:@{}
100-
completionHandler:^(BOOL success) {
101-
XCTAssertFalse(success);
102-
}];
102+
openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
103+
options:@{}
104+
completionHandler:^(BOOL success) {
105+
XCTAssertFalse(success);
106+
}];
103107
XCTAssertFalse(result);
104108
OCMReject([self.mockNavigationChannel invokeMethod:OCMOCK_ANY arguments:OCMOCK_ANY]);
105109
}
@@ -109,41 +113,45 @@ - (void)testLaunchUrlWithDeepLinkingDisabled {
109113
.andReturn(@NO);
110114

111115
[self.appDelegate application:[UIApplication sharedApplication]
112-
openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
113-
options:@{}
114-
completionHandler:^(BOOL success) {
115-
XCTAssertFalse(success);
116-
}];
116+
openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
117+
options:@{}
118+
completionHandler:^(BOOL success) {
119+
XCTAssertFalse(success);
120+
}];
117121
XCTAssertFalse(result);
118122
OCMReject([self.mockNavigationChannel invokeMethod:OCMOCK_ANY arguments:OCMOCK_ANY]);
119123
}
120124

121125
- (void)testLaunchUrlWithQueryParameterAndFragment {
122126
OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
123127
.andReturn(@YES);
124-
OCMStub([self.mockNavigationChannel invokeMethod:@"pushRouteInformation"
125-
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}]).andReturn(@YES);
128+
OCMStub([self.mockNavigationChannel
129+
invokeMethod:@"pushRouteInformation"
130+
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}])
131+
.andReturn(@YES);
126132
[self.appDelegate
127-
application:[UIApplication sharedApplication]
128-
openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test#fragment"]
129-
options:@{}
130-
completionHandler:^(BOOL success) {
131-
XCTAssertTrue(success);
132-
}];
133+
application:[UIApplication sharedApplication]
134+
openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test#fragment"]
135+
options:@{}
136+
completionHandler:^(BOOL success) {
137+
XCTAssertTrue(success);
138+
}];
133139
OCMVerifyAll(self.mockNavigationChannel);
134140
}
135141

136142
- (void)testLaunchUrlWithFragmentNoQueryParameter {
137143
OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
138144
.andReturn(@YES);
139-
OCMStub([self.mockNavigationChannel invokeMethod:@"pushRouteInformation"
140-
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}]).andReturn(@YES);
141-
[self.appDelegate application:[UIApplication sharedApplication]
142-
openURL:[NSURL URLWithString:@"http://myApp/custom/route#fragment"]
143-
options:@{}
144-
completionHandler:^(BOOL success) {
145-
XCTAssertTrue(success);
146-
}];
145+
OCMStub([self.mockNavigationChannel
146+
invokeMethod:@"pushRouteInformation"
147+
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}])
148+
.andReturn(@YES);
149+
[self.appDelegate application:[UIApplication sharedApplication]
150+
openURL:[NSURL URLWithString:@"http://myApp/custom/route#fragment"]
151+
options:@{}
152+
completionHandler:^(BOOL success) {
153+
XCTAssertTrue(success);
154+
}];
147155
OCMVerifyAll(self.mockNavigationChannel);
148156
}
149157

@@ -168,8 +176,10 @@ - (void)testReleasesWindowOnDealloc {
168176
- (void)testUniversalLinkPushRouteInformation {
169177
OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
170178
.andReturn(@YES);
171-
OCMStub([self.mockNavigationChannel invokeMethod:@"pushRouteInformation"
172-
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}]).andReturn(@YES);
179+
OCMStub([self.mockNavigationChannel
180+
invokeMethod:@"pushRouteInformation"
181+
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}])
182+
.andReturn(@YES);
173183
NSUserActivity* userActivity = [[NSUserActivity alloc] initWithActivityType:@"com.example.test"];
174184
userActivity.webpageURL = [NSURL URLWithString:@"http://myApp/custom/route?query=test"];
175185
BOOL result = [self.appDelegate

0 commit comments

Comments
 (0)