[AC-6281] Universal links not working on Ti 8.0.x - crashes if app in background or is closed
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | n/a |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2019-06-06T09:07:37.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Titanium SDK & CLI |
| Labels | ios |
| Reporter | Raef Akehurst |
| Assignee | Shak Hossain |
| Created | 2019-06-05T11:14:29.000+0000 |
| Updated | 2019-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).
The same happens to me too. Instead of the black screen it falls out into the springboard.
I just tested by launching my app from a "spotlight".activity which also triggers "continueacitivity" and the app also crashed upon resuming.
Try to use 8_1_X (ti sdk install -b 8_1_X) which fixes this.
8_1_X does fix it. Thanks. (Wish I had thought to try that 6 hours of testing earlier!!!)
[~rpl] can you confirm it also is fixed for you with 8.1?
yes fixed!
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:
Could you point us to the commit that fixed that? What is the estimated release date of 8.1.0?
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 <…>OK for the last part I figured out I should listen for continueactivity event and not use getArguments