範例ContextHub Store候選項

ContextHub提供數種範例商店候選項目,供您在解決方案中使用。 每個範例都提供下列資訊:

  • 在何處尋找原始碼,以便您開啟它以用於學習。
  • 如何設定您從商店候選者建立的商店。
  • 儲存資料的結構,以便您訪問。
警告

範例商店候選項目會作為參考設定提供,以協助您為專案建立專屬的設定,因此不應直接使用。

aem.segmentation Store Candicated

儲存已解決和未解析的ContextHub區段。 自動從ContextHub SegmentManager中擷取區段。

源位置

/libs/settings/cloudsettings/legacy/contexthub/segmentation

基本實施

aem.segmentation Store候選項會延伸ContextHub.Store.PersistedJSONPStore

設定

當您建立aem.segmentation商店時,不需要提供詳細的設定。 預設配置指定ContextHub段定義的位置。

{
   "service":{
      "jsonp":false,
      "timeout":1000,
      "path":"/etc/segmentation/contexthub.segment.js"
   }
}

contexthub.geolocation Store Candicate

contexthub.geolocation範例商店候選者使用Google地圖來取得並儲存有關用戶端位置的資訊。

源位置

/libs/settings/cloudsettings/legacy/contexthub/geolocation

基本實施

contexthub.geolocation儲存候選擴展ContextHub.Store.PersistedJSONPStore

設定

預設設定會指定Google服務的相關資訊以及初始經緯度座標。

{
        "service": {
            "jsonp": false,
            "timeout": 1000,
            "ttl": 1800000,
            "secure": false,
            "host": "maps.googleapis.com",
            "port": 80,
            "path": "/maps/api/geocode/json"
        },

        "eventDeferring": 16,

        "html5coordinatesDiscoveryAPI": {
            "timeout": 30000,
            "ttl": 900000,
            "highAccuracy": false
        },

        "initialValues": {
            "latitude": 37.331375,
            "longitude": -121.893992
        }
    }

資料項目

商店使用類似下列範例的資料樹:

{
   "latitude":"37.331375",
   "longitude":"-121.893992"
}
注意

Chrome 50.x中引入的安全性政策要求所有與地理位置相關的呼叫都必須透過安全連線進行。 因此,如果AEM也在https上執行,AEM會強制將https用於地理位置API呼叫。 否則,會使用http來符合相同來源的原則。 如需Chrome變更的詳細資訊,請參閱此Google部落格文章

contexthub.surferinfo範例商店候選項

儲存有關目前用戶端環境的資訊,例如裝置、視窗、瀏覽器、日期和時間。

源位置

/libs/settings/cloudsettings/legacy/contexthub/surferinfo

基本實施

contexthub.datetime儲存候選項擴展ContextHub.Store.PersistedStore

設定

預設配置繼承自ContextHub.Store.PersistedStore

資料項目

使用此儲存候選項的儲存具有類似以下示例的資料樹:

{
   "display":{
      "resolution":{
         "width":1440,
         "height":900
      },
      "devicePixelRatio":1,
      "colorDepth":24,
      "nrOfColors":16777216,
      "pixelsPerInch":96,
      "orientation":{
         "mode":"landscape",
         "direction":"normal"
      }
   },
   "window":{
      "dimension":{
         "width":1395,
         "height":652
      },
      "percentageUsage":0.7
   },
   "browser":{
      "version":"39.0",
      "family":"Firefox",
      "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:39.0) Gecko/20100101 Firefox/39.0"
   },
   "device":{
      "category":"Desktop",
      "type":"Desktop",
      "model":"PC",
      "version":""
   },
   "isMobile":true,
   "os":{
      "name":"Mac OS X",
      "version":"10"
   },
   "year":2015,
   "month":7,
   "day":22,
   "hour":14,
   "minutes":1
}

granite.emulators Sample Store Candicate

granite.emulators示例儲存候選儲存有關客戶機設備的資訊。

源位置

/libs/settings/cloudsettings/legacy/contexthub/emulators

基本實施

contexthub.geolocation儲存候選擴展ContextHub.Store.PersistedStore

設定

預設配置包含名為defaultEmulators的陣列,該陣列包含有關不同設備的資訊。 建立商店時,請根據需要在「詳細配置」屬性中使用以下示例中說明的格式提供不同的設備配置檔案:

{
   "defaultEmulators":[
        {
            "id": "iphone-6",
            "title": "iPhone 6",
            "type": "mobile",
            "platform": "iOS",
            "platformVersion": "8.1.3",
            "width": 750,
            "height": 1334,
            "canRotate": true,
            "orientation": "Portrait",
            "device-pixel-ratio": 2
        },
        {
            "id": "iphone-6-plus",
            "title": "iPhone 6 Plus",
            "type": "mobile",
            "platform": "iOS",
            "platformVersion": "8.1.3",
            "width": 1080,
            "height": 1920,
            "canRotate": true,
            "orientation": "Portrait",
            "device-pixel-ratio": 3
        },
        {
            "id": "galaxy-s4",
            "title": "Samsung Galaxy S4",
            "type": "mobile",
            "platform": "Android",
            "platformVersion": "4.4.2 KitKat",
            "width": 1080,
            "height": 1920,
            "canRotate": true,
            "orientation": "Portrait",
            "device-pixel-ratio": 3
        }
    ]
}

資料項目

儲存資料樹與以下示例類似:

{
   "devices":[
      {"id":"native",
      "title":"Native",
      "type":"screen",
      "width":1395,
      "height":374,
      "orientation":"Landscape",
      "platform":"Mac OS X",
      "platformVersion":"10",
      "canRotate":false
      },
      {"id":"ipad-3",
      "title":"iPad 3 / 4 / Air",
      "type":"tablet",
      "platform":"iOS",
      "platformVersion":"8.1.3",
      "width":1536,
      "height":2048,
      "canRotate":true,
      "orientation":"Portrait",
      "device-pixel-ratio":2
      },
      {"id":"iphone-6",
      "title":"iPhone 6",
      "type":"mobile",
      "platform":"iOS",
      "platformVersion":"8.1.3",
      "width":750,
      "height":1334,
      "canRotate":true,
      "orientation":"Portrait",
      "device-pixel-ratio":2
      },
      {"id":"galaxy-s4",
      "title":"Samsung Galaxy S4",
      "type":"mobile",
      "platform":"Android",
      "platformVersion":"4.4.2 KitKat",
      "width":1080,
      "height":1920,
      "canRotate":true,
      "orientation":"Portrait",
      "device-pixel-ratio":3
      }
   ],
   "currentDeviceId":"native",
   "orientations":[
      {"id":"landscape",
      "title":"Landscape"
      },
      {"id":"portrait",
       "title":"Portrait"
      }
   ],
   "currentDevice":{
      "id":"native",
      "title":"Native",
      "type":"screen",
      "width":1395,
      "height":374,
      "orientation":"Landscape",
      "platform":"Mac OS X",
      "platformVersion":"10",
      "canRotate":false
   }
}

granite.profile Store Candicate

儲存目前使用者的相關資訊。

源位置

/libs/settings/cloudsettings/legacy/contexthub/profile

基本實施

contexthub.datetime儲存候選項擴展ContextHub.Store.PersistedJSONPStore

設定

使用下列預設設定。 您不應變更此設定。

{
   "service":{
      "jsonp":false,
      "timeout":1000,
      "path":"${contexthub:/store/profile/path}.infinity.json"
   },
   "initialValues":{"path":"/home/users/a/anonymous"}
}

資料項目

使用此儲存候選項的儲存具有類似以下示例的資料樹:

{
   "displayName":"anonymous",
   "path":"/home/users/6/6zavE_DGre6Ad9Y5E0Ba",
   "avatar":"/etc/designs/default/images/social/avatar.png",
   "authorizableId":"anonymous"
}

本頁內容

Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now
Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now