@@ -192,11 +192,11 @@ class SetupViewController extends StatefulController {
192192 availableIAP.value = details.productDetailsList.first.subscriptionOfferDetails? .first;
193193 }
194194
195- void updateSucceeded (Function finish) async {
195+ void updateSucceeded (Function finish, api. UpdateAccountFinish updateFinish ) async {
196196 finish (true );
197197 updateConnectError ('' );
198198 try {
199- currentAppleUser = await api.doLogin (path: pushService.statePath, account: currentAppleAccount! , anisette : anisette ! , osConfig: config! , cookie : "termsAccepted=true" );
199+ currentAppleUser = await api.doLogin (path: pushService.statePath, account: currentAppleAccount! , osConfig: config! , finish : updateFinish );
200200 ss.settings.userName.value = await api.getUserName (state: currentAppleAccount! );
201201 await doRegister ();
202202 } catch (e) {
@@ -213,80 +213,93 @@ class SetupViewController extends StatefulController {
213213 }
214214
215215 Future <void > updateAccountUi (Function finish) async {
216- var data = await api.updateAccountHeaders (account: currentAppleAccount! );
216+ var ( data, finalI) = await api.updateAccountHeaders (account: currentAppleAccount! , config : config ! );
217217 var request = URLRequest (url: WebUri ("https://inappwebview.dev/" ));
218218
219219 double height = 400 ;
220220 showDialog (
221221 context: Get .context! ,
222222 builder: (context) => StatefulBuilder (
223- builder: (context, setState) {
224- return Center (child: Container (
225- height: height,
226- child: InAppWebView (
227- initialUrlRequest: request,
228- initialData: InAppWebViewInitialData (data: data, baseUrl: WebUri ("https://setup.icloud.com/setup/update_account_ui" )),
229- initialSettings: InAppWebViewSettings (
230- useShouldInterceptAjaxRequest: true ,
231- interceptOnlyAsyncAjaxRequests: false ,
232- useShouldInterceptFetchRequest: true ,
233- ),
234- shouldInterceptAjaxRequest: (controller, request) async {
235- var anisette = await api.getAnisetteHeaders (state: this .anisette! , config: config! );
236- for (var header in anisette.entries) {
237- request.headers! .setRequestHeader (header.key, header.value);
238- }
239- return request;
240- },
241- shouldInterceptFetchRequest: (controller, request) async {
242- var anisette = await api.getAnisetteHeaders (state: this .anisette! , config: config! );
243- request.headers ?? = {};
244- request.headers! .addAll (anisette);
245- return request;
246- },
247- onWebViewCreated: (controller) {
248- controller.addJavaScriptHandler (handlerName: 'log' , callback: (args) {
249- Logger .info ("AppleAccountSetup ${args [0 ]}" );
250- });
251- controller.addJavaScriptHandler (handlerName: 'cancel' , callback: (args) {
252- Get .back ();
253- });
254- controller.addJavaScriptHandler (handlerName: 'updateSucceeded' , callback: (args) {
255- updateSucceeded (finish);
256- Get .back ();
257- });
258- // for ios, also hijacks macos because ios doesn't load prefpange-setupservice.js, loads ios-setupservice.js but that doesn't work
259- controller.addJavaScriptHandler (handlerName: 'confirmWithCallback' , callback: (args) {
260- updateSucceeded (finish);
261- Get .back ();
262- });
263- controller.addJavaScriptHandler (handlerName: 'resizeToWindow' , callback: (args) {
264- setState (() {
265- height = args[1 ];
266- });
267- });
268- controller.injectJavascriptFileFromAsset (assetFilePath: "assets/scripts/AppleAccountSetup.js" );
269- },
270- )),);
271- })
223+ builder: (context, setState) {
224+ return Center (child: Column (
225+ mainAxisSize: MainAxisSize .min,
226+ children: [
227+ Container (
228+ height: height,
229+ child: InAppWebView (
230+ initialUrlRequest: request,
231+ initialData: InAppWebViewInitialData (data: data, baseUrl: WebUri ("https://setup.icloud.com/setup/update_account_ui" )),
232+ initialSettings: InAppWebViewSettings (
233+ useShouldInterceptAjaxRequest: true ,
234+ interceptOnlyAsyncAjaxRequests: false ,
235+ useShouldInterceptFetchRequest: true ,
236+ ),
237+ shouldInterceptAjaxRequest: (controller, request) async {
238+ var anisette = await api.getAnisetteHeaders (state: this .anisette! , config: config! );
239+ for (var header in anisette.entries) {
240+ request.headers! .setRequestHeader (header.key, header.value);
241+ }
242+ return request;
243+ },
244+ shouldInterceptFetchRequest: (controller, request) async {
245+ var anisette = await api.getAnisetteHeaders (state: this .anisette! , config: config! );
246+ request.headers ?? = {};
247+ request.headers! .addAll (anisette);
248+ return request;
249+ },
250+ onWebViewCreated: (controller) {
251+ controller.addJavaScriptHandler (handlerName: 'log' , callback: (args) {
252+ Logger .info ("AppleAccountSetup ${args [0 ]}" );
253+ });
254+ controller.addJavaScriptHandler (handlerName: 'cancel' , callback: (args) {
255+ Get .back ();
256+ });
257+ controller.addJavaScriptHandler (handlerName: 'updateSucceeded' , callback: (args) {
258+ updateSucceeded (finish, finalI);
259+ Get .back ();
260+ });
261+ // for ios, also hijacks macos because ios doesn't load prefpange-setupservice.js, loads ios-setupservice.js but that doesn't work
262+ controller.addJavaScriptHandler (handlerName: 'confirmWithCallback' , callback: (args) {
263+ updateSucceeded (finish, finalI);
264+ Get .back ();
265+ });
266+ controller.addJavaScriptHandler (handlerName: 'resizeToWindow' , callback: (args) {
267+ setState (() {
268+ height = args[1 ];
269+ });
270+ });
271+ controller.injectJavascriptFileFromAsset (assetFilePath: "assets/scripts/AppleAccountSetup.js" );
272+ },
273+ )
274+ ),
275+ TextButton (
276+ onPressed: () {
277+ updateSucceeded (finish, finalI);
278+ Get .back ();
279+ },
280+ child: const Text ('Accept Terms' ),
281+ ),
282+ ],
283+ ));
284+ }
285+ )
272286 );
273287 }
274288
275289 Future <api.LoginState > updateLoginState (api.LoginState ret) async {
276290 if (ret is api.LoginState_NeedsLogin ) {
277- api.IdsUser ? user;
278291 ArcMutexAppleAccountDefaultAnisetteProvider account;
279- (account, ret, user ) = await api.tryAuth (
292+ (account, ret) = await api.tryAuth (
280293 path: pushService.statePath,
281294 conf: config! ,
282295 conn: connection! ,
283296 anisette: anisette! ,
284297
285298 creds: twoFaCreds
286299 );
287- currentAppleUser = user;
288300 currentAppleAccount? .dispose ();
289301 currentAppleAccount = account;
302+ currentAppleUser = await api.tryIcloudLogin (path: pushService.statePath, conf: config! , account: account);
290303 }
291304 if (ret is api.LoginState_NeedsDevice2FA ) {
292305 // subscribe now to not miss the 2fa message
@@ -446,7 +459,7 @@ class SetupViewController extends StatefulController {
446459 Align (
447460 alignment: Alignment .center,
448461 child: Text (
449- "The above message is from Apple.\n Warning: Do not contact Apple support for help with OpenBubbles. For assistance, join our Discord from our website. If you can't login on this Mac , call Apple support.\n ${RustPushBBUtils .modelToUser (devInfo .name )}\n S/N: ${devInfo .serial }\n macOS ${devInfo .osVersion }" ,
462+ "The above message is from Apple.\n Warning: Do not contact Apple support for help with OpenBubbles. For assistance, join our Discord from our website. If you can't login on this Apple Device , call Apple support. When clicking the contact button below, choose 'Get Started,' not 'Chat,' and then choose 'Apple Device.' Do not mention you are using OpenBubbles .\n ${RustPushBBUtils .modelToUser (devInfo .name )}\n S/N: ${devInfo .serial }\n macOS ${devInfo .osVersion }" ,
450463 textAlign: TextAlign .center,
451464 style: Get .textTheme.bodySmall,
452465 )
@@ -456,7 +469,7 @@ class SetupViewController extends StatefulController {
456469 actions: [
457470 if (response.action != null )
458471 TextButton (
459- onPressed: () => launchUrl (Uri .parse (response.action ! .url ), mode: LaunchMode .externalApplication),
472+ onPressed: () => launchUrl (Uri .parse ("https://apple.co/IMFT-mac" ), mode: LaunchMode .externalApplication),
460473 child: Text (response.action! .button, style: context.theme.textTheme.bodyLarge! .copyWith (color: context.theme.colorScheme.primary))),
461474 TextButton (
462475 onPressed: () => Get .back (),
@@ -725,7 +738,7 @@ class SetupViewController extends StatefulController {
725738 if (status.data.toString ().contains ("No device available!" )) {
726739 Timer (const Duration (milliseconds: 100 ), () => pushService.offerHostedRefund (false ));
727740 }
728- throw Exception ("Failed to swap ${status .statusCode }" );
741+ throw Exception ("Failed to swap ${status .statusCode } ${ status . data . toString ()} " );
729742 }
730743
731744 var newTicket = status.data["new_ticket" ];
@@ -1262,4 +1275,4 @@ class _ErrorTextState extends CustomState<ErrorText, String, SetupViewController
12621275 ],
12631276 );
12641277 }
1265- }
1278+ }
0 commit comments