Firebase App Indexing和Gboard贴纸包:hasSticker vs isPartOf vs partOf

时间:2017-09-27 20:22:19

标签: java android firebase-app-indexing gboard

在这个Firebase App Indexing sample code for stickers and sticker packs中,似乎有两种不同的方法来关联"贴纸"使用" StickerPack"。

在方法1中,您创建一个StickerPack,然后通过使用名为" hasSticker":

的键调用put来将贴纸与它相关联。

方法#1

new Indexable.Builder("StickerPack")
   .setName("Snoopy Pack")
   .setImage("content://sticker/pack/canonical/image")
   // see: Support links to your app content section
   .setUrl("http://sticker/pack/canonical/url/snoopy")
   // Set the accessibility label for the sticker pack.
   .setDescription("A sticker pack of Snoopy")
   .put("hasSticker",
        new Indexable.Builder("Sticker")
          .setName("Hey")
          .setImage("http://link/to/the/image/hey")
          .setDescription("A Snoopy hey sticker.")
          .build(),
       new Indexable.Builder("Sticker")
          .setName("Bye")
          .setImage("http://link/to/the/image/bye")
          .setDescription("A Snoopy bye sticker.")
          .build())
   .build());

在方法2中,您创建一个贴纸,然后通过使用名为" isPartOf":

的键调用put来将StickerPack与它相关联。

方法#2

new Indexable.Builder("Sticker")
   .setName("Hey")
   .setImage("http://www.snoopysticker.com?id=1234")
   // see: Support links to your app content section
   .setUrl("http://sticker/canonical/image/hey")
   // Set the accessibility label for the sticker.
   .setDescription("A sticker for hi")
   // Add search keywords.
   .put("keywords", "hey", "snoopy", "hi", "hello")
   .put("isPartOf",
        new Indexable.Builder("StickerPack")
          .setName("Snoopy Pack"))
          .build())
   .build()),

为了使水变得混乱,在这个official google firebase quickstart for app-indexing on github中,他们会遇到麻烦,使用两者的hasSticker和isPartOf方法。并使其更有趣," isPartOf"已将其名称更改为" partOf":

indexableStickerBuilder.put("keywords", "tag1_" + i, "tag2_" + i)
    // StickerPack object that the sticker is part of.
    .put("partOf", new Indexable.Builder("StickerPack")
        .setName(CONTENT_PROVIDER_STICKER_PACK_NAME)
        .build());

同时使用" hasSticker"是否有任何好处?和#34; isPartOf"在定义贴纸及其与StickerPack的关系时 - 或者只是其中一个足够好?

哪个是正确的:" partOf"或" isPartOf" - 或者都是正确的?

0 个答案:

没有答案