Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20131] iOS: Ti.UI.iOS.ApplicationShortcuts does not work on device with LiveView enabled

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2016-11-16T18:48:36.000+0000
Affected Version/sRelease 5.1.1
Fix Version/sn/a
ComponentsiOS, LiveView, Tooling
Labelsios, liveview
ReporterJason Kneen
AssigneeEric Merriman
Created2015-12-11T12:35:21.000+0000
Updated2017-03-27T20:46:16.000+0000

Description

Running the following code on device fails if liveview is enabled. The result is:
TypeError: undefined is not a function (evaluating 'Ti.UI.iOS.createApplicationShortcuts()')
Running with LiveView off works.
if (OS_IOS && Ti.UI.iOS.forceTouchSupported) {
    var appShortcuts = Ti.UI.iOS.createApplicationShortcuts();

    appShortcuts.addDynamicShortcut({
        itemtype: "post_text",
        title: "Text",
        subtitle: "Tap to post text",
        icon: Ti.UI.iOS.SHORTCUT_ICON_TYPE_COMPOSE,
        userInfo: {
            post: {
                type: "text"
            }
        }
    });

    appShortcuts.addDynamicShortcut({
        itemtype: "post_photo",
        title: "Photo",
        subtitle: "Tap to post a photo",
        icon: Ti.UI.iOS.SHORTCUT_ICON_TYPE_CAPTURE_PHOTO,
        userInfo: {
            post: {
                type: "photo"
            }
        }
    });

    appShortcuts.addDynamicShortcut({
        itemtype: "post_video",
        title: "Video",
        subtitle: "Tap to post a video",
        icon: Ti.UI.iOS.SHORTCUT_ICON_TYPE_CAPTURE_VIDEO,
        userInfo: {
            post: {
                type: "video"
            }
        }
    });
}

Comments

  1. Fokke Zandbergen 2015-12-11

    Looks like when you've enabled LiveView the define isn't set: https://github.com/appcelerator/titanium_mobile/search?utf8=✓&q=USE_TI_UIIOSAPPLICATIONSHORTCUTS We scan the code here: https://github.com/appcelerator/titanium_mobile/blob/master/node_modules/titanium-sdk/lib/jsanalyze.js#L102-L145 And set the defines here: https://github.com/appcelerator/titanium_mobile/blob/master/iphone/cli/commands/_build.js#L5440 Could it be that since LiveView replaces the app's app.js it doesn't find these? Then we'd need to fix this by copying in the original app.js (as _app.js) as well with LiveView enabled.
  2. Chee Kiat Ng 2016-02-19

    [~jasonkneen] did you try with our 5.2.0.RC? I tried to reproduce here but I don't see the error.
  3. Hans Knöchel 2016-03-25

    Just pinged Jason via mail. Maybe the <run-on-main-thread/> flag was enabled?
  4. Feon Sua Xin Miao 2016-04-19

    This happens to Ti.UI.create* apis too, i.e Ti.UI.createWindow, Ti.UI.iOS.createNavigationWindow, Ti.UI.createLabel Create a classic titanium app, do ti build -p ios -T device --liveview, launch the app, it fails with similar error:
       [ERROR] Error: invalid method (createTabGroup) passed to UIModule
       [ERROR] File: app.js
       
    This seems like a SDK issue.
  5. Chee Kiat Ng 2016-05-19

    Thanks [~fmiao] this is a good reproducible case. The problem lies where the command call has to include the flag --deploy-type development in order for this to work, because by default, if you target device, it's --deploy-type test I'm not sure if this was by design but leaving a note here first until we decide the best approach to fixing this. Also, if you do this in studio, the flag is --deploy-type development so there won't be an issue.
  6. Hans Knöchel 2016-10-02

    So this is device-only? I know that we include [all defines](https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/defines.h) when running a sim-build and generate the symbols manually for device-builds (see _build.js above). So if this issue affects all Ti.UI namespaces, I'm wondering how this ever worked before then.
  7. Hans Knöchel 2016-11-16

    Just tested with 6.0.0.GA and I'm not able to reproduce this issue anymore. To be validated by the QE team. Thx!
  8. Lee Morris 2017-03-27

    Closing ticket as the issue cannot be reproduced, with reference to the above comments.

JSON Source