You can find many sample XMLs for NEZP in our github repo:
NEZP Demo Source Code (Github)You can achieve rendering a list of friends with corresponding actions such as context switch or a custom action (sending an in-game reward) in 2 ways:
FBInstant.player.getConnectedPlayersAsync()initialData of the createOverlayView APIFBInstant.players key as detailed hereFBInstant.player.getConnectedPlayersAsync() as initialData to the createOverlayView methodFor operator and render each row with the corresponding buttons<For source="{{playerIDs}}" itemName="i">
<!-- Render other player info here -->
<Button onTapEvent="SendCoins_{{i.item}}"></Button>
</For>FBInstant.overlayViews.setCustomEventHandler. More details in the section hereplayerID to each created overlay view per row, and store the mapping of player ID to overlay ID in your local game codeSendCoinsFBInstant.overlayViews.setCustomEventHandler returns an overlayID that you can use to check which playerID it corresponds toYou can render and sort data using dynamic keys in for-loops (e.g. {{scores[{{player.id}}]}}" in the example below).
<View>
<For source="{{players}}" itemName="player" sortKey="{{scores[{{player.id}}]}}" order="DESC">
<View>
<Text content="{{player.name}}" />
<Text content="{{scores[{{player.id}}]}}" />
</View>
</For>
</View>{
"players": [
{
"id": 1,
"name": "Alice"
},
{
"id": 2,
"name": "Bob"
},
{
"id": 3,
"name": "Carol"
}
],
"scores": {
"1": 101,
"2": 222,
"3": 313
}
}| Example | XML Code |
|---|---|
Profile Overlay | <View>
<Image src="{{FBInstant.player.photo}}" className="profilePicture" width="50" />
<Text content="{{FBInstant.player.name}}" className="playerName"/>
</View> |
Profile Overlay with IF Condition | <View>
<View>
<Image className="profilePicture" width="50" src="{{FBInstant.player.photo}}"/>
</View>
<If>
<Condition lhs="{{FBInstant.player.name}}" operator="EQUALS" rhs="Daiwei"/>
<View><Text className="playerName" content="{{FBInstant.player.name}} - in IF!"/></View>
<Else>
<View><Text className="playerName" content="{{FBInstant.player.name}} - in ELSE!"/></View>
</Else>
</If>
</View> |
Friend List Iteration | <View>
<For source="{{FBInstant.player.connectedPlayers}}" itemName="i" sortKey="name">
<View>
<Image className="profilePicture" width="50" src="{{i.photo}}" />
<Text className="playerName" content="{{i.name}}" />
</View>
</For>
</View> |
Friend List Iteration (sorted by dynamic key) | <View>
<For source="{{FBInstant.player.connectedPlayers}}" itemName="player" sortKey="{{scores[{{player.id}}]}}" order="DESC">
<View>
<Image src="{{player.photo}}" style="width:60px; height:60px;" />
<Text content="{{player.name}}" />
<Text content="{{scores[{{player.id}}]}}" />
</View>
</For>
</View> |
Specific Friends/Players (without iteration) | <View>
<Image className="profilePicture" width="50" src="{{FBInstant.players[{{playerID}}].photo}}" />
<Image className="profilePicture" width="50" src="{{FBInstant.players[{{otherPlayerID}}].photo}}" />
</View> |