locked
Secondary tiles: arguments parameter needed in order to get the app activated?

    Question

  • I've just noticed that passing an empty string for the arguments property in a secondary tile won't activate my app when the user taps it. Is this by design or is this a bug?I've looked at the docs and they only say this about the property (http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.startscreen.secondarytile.arguments.aspx):

    Gets or sets an app-defined set of information that is passed from the secondary tile to the app on activation. This property is required when you create a tile.

    It says nothing about empty strings, so if empty string isn't a valid value, shouldn't it throw an exception?

    thanks.


    Luis Abreu

    Tuesday, April 24, 2012 12:07 PM

Answers

  • This is a better workaround (pass null):

    var tile = new Windows.UI.StartScreen.SecondaryTile(newTileID, newTileShortName, newTileDisplayName, null, Windows.UI.StartScreen.TileOptions.showNameOnLogo, uriLogo);

    I suspect this is what the dev team will say is the correct syntax and update the documentation.

    -Jeff


    Jeff Sanders (MSFT)

    Thursday, April 26, 2012 2:31 PM
    Moderator

All replies

  • It seems like you have a problem with your code.  You do not have to pass arguments and an empty string works fine.  Modify the secondarytiles sdk sample to use an empty string and you will see that it works.

    -Jeff


    Jeff Sanders (MSFT)

    Tuesday, April 24, 2012 12:32 PM
    Moderator
  • Thanks Jeff.

    I'll investigate and report back


    Luis Abreu

    Tuesday, April 24, 2012 8:55 PM
  • Ok, I've done what you said and I've replaced the arguments parameter with an empty string and I'm getting the same behaviour I've described before: the tile gets pinned to the start screen, but clicking over it doesn't do anything.

    Btw, here's the code I'm using to create mine. Replacing the empty string with a non empty string does activate the app, but I haven't found anything in docs that says that non empty string is needed for activating the app.

    var tile = Tile.SecondaryTile(id, nome, nome, "", Tile.TileOptions.showNameOnLogo | Tile.TileOptions.showNameOnWideLogo, uriLogo, uriWideLogo);
            tile.foregroundText = Tile.ForegroundText.light;
            tile.backgroundColor = "#880015";
            tile.smallLogo = uriSmallLogo;
            var btRect = document.getElementById("bt").getBoundingClientRect();
            tile.requestCreateAsync({ x: btRect.left, y: btRect.top })
                .done(function (criado) {
                    document.getElementById("info").innerHTML += ( criado ?
                        "Tile secundário foi criado" : "Tile secundário não foi criado" ) + "<br>";
                });


    Luis Abreu

    Tuesday, April 24, 2012 9:12 PM
  • What I was suggesting is that your code to handle the activation is broken.

    Start with the sample, ensure that it works correctly on your system, then compare this to your code to see where you are failing.  Make sense?

    -Jeff


    Jeff Sanders (MSFT)

    Wednesday, April 25, 2012 1:34 PM
    Moderator
  • Hello again Jeff.

    Yes, it does, but once again, I think we're not communicating.

    what I'm telling  you is that if you open the sample and replace the arguments parameter with an empty string, then clicking over that secondary tile won't launch the application. Just to be clear, I'm saying that replacing this line in the pinByElement:

    var tile = new Windows.UI.StartScreen.SecondaryTile(newTileID, newTileShortName, newTileDisplayName, newTileActivationArguments, Windows.UI.StartScreen.TileOptions.showNameOnLogo, uriLogo);

    with this one:

    var tile = new Windows.UI.StartScreen.SecondaryTile(newTileID, newTileShortName, newTileDisplayName, "", Windows.UI.StartScreen.TileOptions.showNameOnLogo, uriLogo);

    is all it takes to reproduce the behavior I've mentioned (ie, clicking over the secondary tile won't open the app when I use an empty string for the arguments constructor). 


    Luis Abreu

    Thursday, April 26, 2012 7:56 AM
  • Hey Luis,

    Nope, this time we are communicating fine!  I did exactly as you said with the tiles sample and it works fine (pinByElementAsync is the function not pinByElement).

    Are you confident that you have made no other changes to the sample?  Try uninstalling the sample app too.

    -Jeff


    Jeff Sanders (MSFT)

    Thursday, April 26, 2012 12:13 PM
    Moderator
  • Hello again Jeff.

    Well, this is odd. I've confirmed here http://code.msdn.microsoft.com/windowsapps/Secondary-Tiles-Sample-edf2a178/sourcecode?fileId=44810&pathId=1754477665 that pinByElement is that function that gets called for pinning the secondary tile when you choose the first option of the list (aren't you choosing that option to add the secondary pin?). According to the code:

    id("scenario1PinButton").addEventListener("click", scenario1PinSecondaryTile, false);

    And then, we have:

    function scenario1PinSecondaryTile() {
            sdkSample.displayStatus("");

            // In this scenario, we're pinning a tile.
            // There is a helper function above to make it clear how to do the actual pin operation.
            // That helper function, pinByElementID, will also be good to have later when we want to re-use it in other scenarios.
            //
            // Let's go ahead and call that now, passing in properties that we'll use when constructing our tile to pin.

            pinByElement(document.getElementById("scenario1PinButton"), "SecondaryTile.tilePinnedInScenario1", "Title text shown on the tile", "Name of the tile the user sees when searching for the tile");
        }

    As you can see, if you're clicking over the button shown when option 1 is selected in the list, you'll  end up calling the function I've mentioned, right?

    Out of curiosity, I've went ahead and replaced the arguments parameter with an empty string. After that, I've went ahead and picked option 8 to create the secondary tile. guess what? it won't launch the app with an empty string as I've been complaining for some time now :)

    Can you please confirm this again?

    thanks.


    Luis Abreu

    Thursday, April 26, 2012 12:31 PM
  • Got it!

    Lots of details are good :-).  I will file a bug to fix the documentation (saying that you must pass arguments of some sort) or investigate to see if we should allow an empty string for aguments.  You can work around the issue by passing dummy arguments or a special string that you recognise in your app like "NoArgumentsHereSoMoveAlong"

    Thanks Luis,

    Jeff.


    Jeff Sanders (MSFT)

    Thursday, April 26, 2012 1:25 PM
    Moderator
  • Thanks.

    Please let me know if this is a bug or if it's the docs that are out of sync...


    Luis Abreu

    Thursday, April 26, 2012 1:35 PM
  • This is a better workaround (pass null):

    var tile = new Windows.UI.StartScreen.SecondaryTile(newTileID, newTileShortName, newTileDisplayName, null, Windows.UI.StartScreen.TileOptions.showNameOnLogo, uriLogo);

    I suspect this is what the dev team will say is the correct syntax and update the documentation.

    -Jeff


    Jeff Sanders (MSFT)

    Thursday, April 26, 2012 2:31 PM
    Moderator
  • Thanks Jeff.

    I must confess that I find that really weird. I mean, is there any good reason for not launching an app after the user taps in a tile? Won't that break things? One more thing: allowing null instead of an empty string is something which really isn't intuitive...


    Luis Abreu

    Friday, April 27, 2012 7:50 AM
  • That is why I filed the bug :-)


    Jeff Sanders (MSFT)

    Friday, April 27, 2012 11:40 AM
    Moderator