Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6281] Universal links not working on Ti 8.0.x - crashes if app in background or is closed

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2019-06-06T09:07:37.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsios
ReporterRaef Akehurst
AssigneeShak Hossain
Created2019-06-05T11:14:29.000+0000
Updated2019-06-13T11:17:17.000+0000

Description

When you try and open an app from a universal link while the app is in the background or not open, the app will open and then crash (black screen) with no errors in the log. It works in Ti 7.5.1.GA. Does not work with Ti 8.0.0.GA or Ti 8.0.1.GA. Steps to reproduce: 1. Create a test project (make the project name com.picsafe.med to simulate my app): $ mkdir Temp $ cd Temp $ ti create $ alloy new 2. in tiapp.xml add:
    <ios>
      ...
      <entitlements>
        <dict>
          <key>aps-environment</key>
          <string>production</string> <!-- Either development or production -->
        </dict>
        <dict>
          <key>com.apple.developer.associated-domains</key>
          <array>
              <string>applinks:my.picsafe.com</string>
              <string>webcredentials:my.picsafe.com</string>
          </array>
        </dict>
    </entitlements>
3. And also add:
    <ios>
      ...
      <plist>
        ...
	<dict>
        <key>NSUserActivityTypes</key>
        <array>
          <string>com.picsafe.med.universalLink</string>
        </array>
      </dict>
      <dict>
        <key>UIBackgroundModes</key>
        <array>
          <string>fetch</string>
          <string>remote-notification</string>
        </array>
      </dict>
			
			<dict>
				<key>CFBundleURLTypes</key>
        <array>
          <dict>
            <key>CFBundleURLName</key>
            <string>com.picsafe.med</string>
            <key>CFBundleURLSchemes</key>
            <array>
              <string>picsafe</string>
            </array>
          </dict>
        </array> 
4. Add the following in app/controllers/index.js:
Ti.App.iOS.addEventListener("continueactivity", function(e) {

  if (e.activityType === "NSUserActivityTypeBrowsingWeb") {
    console.log("PicSafe has been opened from a URL:", e.webpageURL);
  }

  // console.log("continueactivity", JSON.stringify(Ti.App.getArguments()));
});

$.win.addEventListener("open", function() {
  console.log("PicSafe has been opened.");
});
5. Build the project $ ti build --platform ios --target simulator 6. Put the app into the background. 7. Run the following from the command line: $ xcrun simctl openurl booted "https://my.picsafe.com/app" 8. The app will open and then go to a black screen. Expected result (and result on Ti 7.5.1.GA: The app opens and displays correctly. Observes result: The app opens then crashes (either back to the springboard, or shows a black screen).

Comments

  1. Aleksey Gureiev 2019-06-05

    The same happens to me too. Instead of the black screen it falls out into the springboard.
  2. roeland p 2019-06-05

    I just tested by launching my app from a "spotlight".activity which also triggers "continueacitivity" and the app also crashed upon resuming.
  3. Hans Knöchel 2019-06-05

    Try to use 8_1_X (ti sdk install -b 8_1_X) which fixes this.
  4. Raef Akehurst 2019-06-05

    8_1_X does fix it. Thanks. (Wish I had thought to try that 6 hours of testing earlier!!!)
  5. Rene Pot 2019-06-06

    [~rpl] can you confirm it also is fixed for you with 8.1?
  6. roeland p 2019-06-06

    yes fixed!
  7. Aleksey Gureiev 2019-06-07

    This one is fixed for me too, but I discovered that the app still crashes when you try to open a file that is linked to the app from email. We are sending reports in email and the app is registered to handle them. When you click on the report the app crashes on Ti.App.getArguments() call with:
       [ERROR]     message = "-[NSUserActivity boundBridge:withKrollObject:]: unrecognized selector sent to instance 0x281723cc0";
       [ERROR]     nativeStack = "3   CoreFoundation  0x00000001cca1e7bc <redacted> + 1412\n4   CoreFoundation  0x00000001cca2046c _CF_forwarding_prep_0 + 92\n5   TitaniumKit0x000000010262394c -[KrollBridge registerProxy:] + 148\n6   TitaniumKit0x00000001026049e0 TiBindingTiValueFromProxy + 492\n7   TitaniumKit0x0000000102603d08 TiBindingTiValueFromNSDictionary + 220\n8   TitaniumKit0x0000000102603d08 TiBindingTiValueFromNSDictionary + 220\n9   TitaniumKit0x000000010265bbec KrollCallAsFunction + 556\n10  JavaScriptCore  0x00000001d3d92788 <redacted> + 348\n11  JavaScriptCore  0x00000001d4474eac <redacted> + 352\n12  JavaScriptCore  0x00000001d3d69a08 <redacted> + 29992\n13  JavaScriptCore  0x00000001d3d69a1c <redacted> + 30012\n14  JavaScriptCore  0x00000001d3d622e4 <redacted> + 308\n15  JavaScriptCore  0x00000001d43d15d4 <redacted> + 424\n16  JavaScriptCore  0x00000001d4588b78 _ZN3JSC12profiledCallEPNS_9ExecStateENS_15ProfilingReasonENS_7JSValueENS_8CallTypeERKNS_8CallDataES3_RKNS_7ArgListE + 188\n17  JavaScriptCore  0x00000001d3d97cbc JSObjectCallAsFunction + 368\n18  TitaniumKit0x0000000102639db0 TiBindingEventProcess + 680\n19  TitaniumKit0x0000000102659cb8 -[KrollContext invoke:] + 116\n20  TitaniumKit0x0000000102659d28 -[KrollContext enqueue:] + 92\n21  TitaniumKit0x00000001026618bc TiBindingRunLoopEnqueue + 92\n22  TitaniumKit0x0000000102660238 -[TiProxy fireEvent:withObject:withSource:propagate:reportSuccess:errorCode:message:] + 176";
       
  8. Nikos Poulios 2019-06-13

    Could you point us to the commit that fixed that? What is the estimated release date of 8.1.0?
  9. Nikos Poulios 2019-06-13

    According to my tests with 8_1_X, app resumes when in background using universal links, but when the app is not running and is launched by universal link, I get the following error and app is stuck on splash screen
       default	13:48:16.024421 +0300	BayerNet DEV	[ERROR] Application received error: /AppController.js:404
           var launchArgs = Ti.App.getArguments();
                                                ^
       -[NSUserActivity boundBridge:withKrollObject:]: unrecognized selector sent to instance 0x280102c60
           at [native code]
           at getLaunchArgumentsURL@/core/js/controllers/AppController.js:404:41)
           at showInterface@/core/js/controllers/AppController.js:338:36)
           at start@/core/js/controllers/AppController.js:184:20)
           at /app.js:1:171)
           at global code@/app.js:2:70)
           at require@[native code]
           at /ti.main.js:9535:10)
           at loadAsync@/ti.main.js:9461:13)
           at global code@/ti.main.js:9532:10)
       
       TitaniumKit 0x00000001012014c0 -[KrollBridge loadCommonJSModule:withSourceURL:] + 472
       TitaniumKit 0x0000000101201e2c -[KrollBridge loadJavascriptText:fromFile:withContext:] + 84
       TitaniumKit 0x0000000101203358 -[KrollBridge require:path:] + 428
       TitaniumKit 0x00000001012398f8 CommonJSRequireCallback + 120
       JavaScriptCore 0x00000001d798faa4 <redacted> + 348
       Ja<…>
       
       and
       
       [ERROR] Application received error: /ti.main.js:9535
         require('./app'); // This event is to be fired after "app.js" execution. Reasons:
                 ^
       Module "app.js" failed to leave a valid exports object
           at require@[native code]
           at /ti.main.js:9535:10)
           at loadAsync@/ti.main.js:9461:13)
           at global code@/ti.main.js:9532:10)
       
       TitaniumKit 0x00000001011ff95c -[KrollBridge evalFileOnThread:context:] + 884
       TitaniumKit 0x00000001012382f0 -[KrollInvocation invoke:] + 88
       TitaniumKit 0x0000000101238f94 -[KrollContext invoke:] + 116
       TitaniumKit 0x00000001012008c8 -[KrollBridge didStartNewContext:] + 2816
       TitaniumKit 0x0000000101239840 -[KrollContext main] + 1160
       libdispatch.dylib 0x00000001d007ca38 <redacted> + 24
       libdispatch.dylib 0x00000001d007d7d4 <redacted> + 16
       libdispatch.dylib 0x00000001d002b004 <redacted> + 1068
       CoreFoundation 0x00000001d05cec1c <redacted> + 12
       CoreFoundation 0x00000001d05c9b54 <redacted> + 1924
       CoreFoundation 0x00000001d05c90b0 CFRunLoopRunSpecific + 436
       GraphicsServices <…>
       
  10. Nikos Poulios 2019-06-13

    OK for the last part I figured out I should listen for continueactivity event and not use getArguments

JSON Source