Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27354] iOS13 - Ti.App.getArguments().url undefined when resuming

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2019-10-09T13:54:09.000+0000
Affected Version/sRelease 8.1.0
Fix Version/sRelease 8.2.1
ComponentsiOS
LabelsengSchedule, ios
ReporterJoren Vos
AssigneeVijay Singh
Created2019-08-23T13:25:46.000+0000
Updated2019-10-30T02:35:46.000+0000

Description

It seems that Ti.App.getArguments().url is undefined when you open an already-opened app using an URL-scheme in iOS 13. In attachment, there is a sample project that runs as expected on iOS 12 but is broken on iOS 13 beta. There are two apps, app A and app B. When you open app A and press on the button to open app B, you’ll see the alert containing the URL-scheme that was used to open app B. When you try to go back to app A using URL-scheme, after resuming in app A the Ti.App.getArguments().url returns the URL-scheme that was used to open app A in iOS 12. In iOS 13, navigating from app B to app A will return undefined for Ti.App.getArguments().url

Attachments

FileDateSize
FirstApp.zip2019-08-23T13:27:20.000+00008661363
ios12-working.MP42019-08-23T13:26:02.000+00002563712
ios13-broken.MP42019-08-23T13:26:07.000+00003581543
SecondApp.zip2019-08-23T13:27:25.000+00008661416

Comments

  1. Brenton House 2019-08-23

    [~cwilliams] FYI
  2. Hans Knöchel 2019-08-25

    tl;dr: The SDK needs to properly guard the "source" parameter before returning improper values, but most cases are not affected by that. We see a related issue where our Swift extension crashes because the openURL: delegate method returns improper values to the underlaying API's, causing these issues. It can also be seen in a crash when logging in with Ti.Facebook where the app crashes because the sourceApplication param of the bubbled delegate method is nil. *EDIT*: The source is also undefined with iOS 13, which is native behavior: https://forums.developer.apple.com/thread/119118 *EDIT 2*: For your issue, you can easily resolve it by using the handleurl event in Ti.App.iOS which is generally more stable than resumed. [~jvos] This fixes your issue (which is not Titanium related in that case):
       Ti.App.iOS.addEventListener('handleurl', event => {
           setTimeout(() => {
               alert(JSON.stringify(event));
           }, 1000);
       });
       
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       win.open();
       
    Our issue is related to Ti.GoogleSignIn, but the actual issue is an SDK issue where the (nil) source is returned as a NSNull type, causing some SDK's to handle it improperly, since it's either nil or a string, nut not NSNull, so the SDK should be updated to handle it properly.
  3. Vijay Singh 2019-09-23

    1. While debugging I found that - Sequence of calling following delegate methods has changed - Function1 - [-(void)applicationWillEnterForeground:(UIApplication *)application](https://github.com/appcelerator/titanium_mobile/blob/c6978221163cb9a628859b39042fa697b6065471/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m#L1086) Function2 - [- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options](https://github.com/appcelerator/titanium_mobile/blob/c6978221163cb9a628859b39042fa697b6065471/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m#L426) In iOS 12, Function1 is called before Function2. In iOS 13 Function2 is called before Function1. Inside Function1 [url](https://github.com/appcelerator/titanium_mobile/blob/c6978221163cb9a628859b39042fa697b6065471/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m#L1096) key is removed. So to avoid issue related Ti.App.getArguments().url being undefined use "handleurl" event as mentioned by Hans. 2. Regarding "source" property NSNull is set [here](https://github.com/appcelerator/titanium_mobile/blob/c6978221163cb9a628859b39042fa697b6065471/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m#L435) if it is nil. I don't think we should set NSNull for this. I'll put a guard and will not set "source" if it nil.
  4. Vijay Singh 2019-09-25

    PR (master) - https://github.com/appcelerator/titanium_mobile/pull/11242 PR (8_2_X) - https://github.com/appcelerator/titanium_mobile/pull/11243
  5. Ebenezer Boateng 2019-10-02

    FR Failed - Information in PR (8_2_X)
  6. Sohail Saddique 2019-10-02

    FR Failed (PR Master) Information in PR: https://github.com/appcelerator/titanium_mobile/pull/11242#issuecomment-537533063
  7. Sohail Saddique 2019-10-03

    Changes that have been made alleviate the bug. FR Passed.
  8. Christopher Williams 2019-10-03

    merged to master and 8_2_X
  9. Sohail Saddique 2019-10-09

    Verified using builds: 8.2.1.v20191008121020 8.3.0.v20191008081818 Ticket closed.
  10. Pietro Granati 2019-10-16

    For me is undefined with 8.2.1.v20191010112656
  11. Xavier Alfeiran 2019-10-28

    Undefined also with 8.2.1, with iOS 13.1.3
  12. Pietro Granati 2019-10-29

    @Xavier Alfeiran I solved using handle url event:
        Ti.App.iOS.addEventListener("handleurl", function() {
        		if (!_.isUndefined(Ti.App.getArguments().url)) {
        			Ti.API.info("RESUME URLSCHEME: " + Ti.App.getArguments().url);
        			var url = Ti.App.getArguments().url;
        			var ods = url.substring(("scheme://").length, url.length);
        			if (!Alloy.Globals.itinerarioAperto) {
        				getODS(ods);
        			}
        		}
        	});
        
  13. Xavier Alfeiran 2019-10-30

    it worked nice, thank you

JSON Source