Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23297] Calling Ti.App.getArguments() crashes app when launched via new App Shortcuts

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-07-04T04:07:43.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.0.0, Release 5.4.0
ComponentsiOS
Labelsios, shortcuts
ReporterMatthew Delmarter
AssigneeHans Knöchel
Created2016-03-29T23:44:48.000+0000
Updated2016-07-28T21:48:54.000+0000

Description

I am testing out the new support for Application Shortcuts as described here: http://www.appcelerator.com/blog/2015/11/ios-9-3d-touch-sample-app/ I have the shortcuts showing when I press on the app icon - perfect. However as soon as the app launches it crashes. And the reason is that when the app is launched or resumed I perform some checks for incoming parameters using the Ti.App.getArguments(). And it seems that whenever the app is *launched* using a App Shortcut, then any subsequent call to Ti.App.getArguments() crashes the app. The crash error message is: {noformat} [UIApplicationShortcutItem boundBridge:withKrollObject:]: unrecognized selector sent to instance 0x137d65370 {noformat} I will attach a sample project which has a App Shortcut set in the tiapp.xml file as follows:
<key>UIApplicationShortcutItems</key>
<array>
  <dict>
    <key>UIApplicationShortcutItemIconType</key>
    <string>UIApplicationShortcutIconTypeSearch</string>
    <key>UIApplicationShortcutItemTitle</key>
    <string>Search</string>
    <key>UIApplicationShortcutItemType</key>
    <string>search</string>
    <key>UIApplicationShortcutItemUserInfo</key>
    <dict/>
  </dict>
</array>
And a very simple app.js using native code:
var win = Ti.UI.createWindow({
   backgroundColor: 'blue'
});
win.open();

Ti.App.getArguments();
Make sure the app is force closed. Then launch the app via the App Shortcut (not the app icon). It will crash with the above error. Tested on my iPhone 6S Plus.

Attachments

FileDateSize
IMG_2008.jpg2016-03-29T23:49:44.000+0000347438
IMG_2009.jpg2016-03-29T23:49:52.000+0000663529
Test3dTouch.zip2016-03-29T23:43:55.000+000065562

Comments

  1. Matthew Delmarter 2016-03-29

  2. Matthew Delmarter 2016-03-29

    Screenshots of the app running on my iPhone 6S Plus
  3. Sharif AbuDarda 2016-03-30

    Hello, According to the closed ticket link that you provided, It looks like the issue is fixed in SDK 5.4.0. I would suggest building your app with SDK 5.4.0 and see if the error still exists. Please be informed that currently SDK 5.4.0 is a beta release and possibly lead to other issues. You can download the SDK from here http://builds.appcelerator.com.s3.amazonaws.com/index.html#master Please, Build the app in SDK 5.4.0 and see if the issue is fixed or not. Feel free to reply on any other issues too. Regards, Sharif
  4. Matthew Delmarter 2016-03-30

    @Sharif thanks for the suggestion to try SDK 5.4.0. I downloaded the latest build of this SDK and built/ran the app on my iPhone 6S Plus to see if it fixed the issue. Unfortunately it had exactly the same issue. It did not fix the problem.
  5. Matthew Delmarter 2016-04-12

    Really hoping to see this assigned and resolved? The new app shortcuts are useless to me until this is fixed...
  6. David Fox 2016-05-01

  7. Hans Knöchel 2016-05-03

    Hey everyone. First of all, thanks for all the information, appreciate that! So its looking like TIMOB-23232 is a duplicate of TIMOB-20183 and this ticket is fixed by that one. So please try out the [latest master](http://builds.appcelerator.com/#master) to check if that solved your issue. If not, we probably need to apply the same fix for the application shortcuts launch options. Thanks!
  8. Matthew Delmarter 2016-05-03

    I am a little confused by all this back and forth. Yes TIMOB-20183 was resolved by SDK 5.4.0. The PR that resolved 20183 is here: https://github.com/appcelerator/titanium_mobile/pull/7614 @Sharif already suggested right at the outset that I try 5.4.0 to see if it fixes the problem. I already tried it on 31 March and clearly stated "It did not fix the problem". I also directly applied the same code fix from the PR and it did +not+ fix the problem. So we are already past this suggestion... unless you mean that the same fix needs to be applied to _other areas_ of the SDK code? i.e. not the same chunk of code inside iphone/Classes/TiApp.m?
  9. Hans Knöchel 2016-07-03

    PR: https://github.com/appcelerator/titanium_mobile/pull/8105 Steps to test: 0. Make sure you have a device that has at least iOS 9 and supports Force-Touch (iPhone 6S, iPhone 6S Plus) 1. Include the following in the <ios/> section of your tiapp.xml:
       <key>UIApplicationShortcutItems</key>
       <array>
         <dict>
           <key>UIApplicationShortcutItemIconType</key>
           <string>UIApplicationShortcutIconTypeSearch</string>
           <key>UIApplicationShortcutItemTitle</key>
           <string>Search</string>
           <key>UIApplicationShortcutItemType</key>
           <string>search</string>
           <key>UIApplicationShortcutItemUserInfo</key>
           <dict/>
         </dict>
       </array>
       
    2. Copy the following in your app.js
       var win = Ti.UI.createWindow({
          backgroundColor: 'blue'
       });
       win.open();
        
       Ti.App.getArguments();
       
       Ti.App.iOS.addEventListener("shortcutitemclick", function(e){
           Ti.API.info("shortcutitemclick Event Fired");
           alert(e);
       });
       
    3. Launch the app and put it in background by tapping the home button 4. Launch the app using the shortcut in the home-screen - No crash should appear and the shortcutitemclick event should be triggered. 5. Close the app completely by closing it from multitasking 6. Open the app using the shortcut again - No crash should appear and the shortcutitemclick event should be triggered. 7. Thank you!
  10. Chee Kiat Ng 2016-07-04

    [~hansknoechel] PR Merged. Please do a 5.4.0 back port.
  11. Matthew Delmarter 2016-07-04

    I haven't had a chance to test this yet, but I have been waiting patiently for resolution and wanted to say thanks for the fix. Much appreciated.
  12. Hans Knöchel 2016-07-04

    PR (5_4_X): https://github.com/appcelerator/titanium_mobile/pull/8107 [~mdelmarter] I am happy to hear that! Feel free to verify the fix using the [latest master build|builds.appcelerator.com/#master] that should be available in a few minutes.
  13. Chee Kiat Ng 2016-07-04

    Backport PR merged.
  14. Matthew Delmarter 2016-07-06

    Backported changes to 5.2.1 - confirmed as working perfectly.
  15. Wilson Luu 2016-07-28

    Closing ticket as fixed. Verified, while using Hans's test code, that the app does not crash when calling Ti.App.getArguments via App Shortcuts. Tested on: Appc CLI NPM: 4.2.7 Appc CLI Core: 5.4.0-36 Arrow: 1.8.2 SDK: 5.4.0.v20160727143921 Node: v4.4.7 OS: Mac OS X (10.11.6) Xcode: 7.3.1 Device: iphone 6s plus (9.3.1)

JSON Source