[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
OK for the last part I figured out I should listen for continueactivity event and not use getArguments