Skip to content

Commit 9fe001a

Browse files
authored
Removed reference to version (#80)
* fix(readme): Removed reference to version * fix(readme): Added UserId fixes
1 parent 9999e96 commit 9fe001a

File tree

1 file changed

+71
-63
lines changed

1 file changed

+71
-63
lines changed

README.md

Lines changed: 71 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PubNub Unity SDK (V4)
1+
# PubNub Unity SDK (V6)
22

33
[![Build Status](https://travis-ci.com/pubnub/unity.svg?branch=master)](https://travis-ci.com/pubnub/unity) [![Build status](https://ci.appveyor.com/api/projects/status/1p3494pnt6rgqdsm/branch/master?svg=true)](https://ci.appveyor.com/project/PubNub/unity)
44

@@ -12,83 +12,92 @@ You will need the publish and subscribe keys to authenticate your app. Get your
1212

1313
## Configure PubNub
1414

15-
1. Download the PubNub Unity package from [this repository](https://github.com/pubnub/unity/releases/download/v6.0.6/PubNub.unitypackage).
15+
1. Download the PubNub Unity package from [this repository](https://github.com/pubnub/unity/releases/download/v6.0.5/PubNub.unitypackage).
1616

17-
2. Import it to your Unity project by going to Assets -> Import Package -> Custom Package.
17+
2. Import the package to your Unity project by going to Assets > Import Package > Custom Package.
1818

1919
3. Configure your keys:
2020

2121
```csharp
22+
using PubNubAPI;
2223
PNConfiguration pnConfiguration = new PNConfiguration();
2324
pnConfiguration.SubscribeKey = "my_subkey";
2425
pnConfiguration.PublishKey = "my_pubkey";
2526
pnConfiguration.SecretKey = "my_secretkey";
2627
pnConfiguration.LogVerbosity = PNLogVerbosity.BODY;
27-
pnConfiguration.UUID = "myUniqueUUID";
28+
pnConfiguration.UserId = "myUniqueUserId";
2829
```
2930

31+
4. If your Unity application contains existing [Assembly Definitions](https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html), you might receive [CS0246 compiler errors](https://support.unity.com/hc/en-us/articles/206116726-What-is-CS0246-), as the `PubNubAPI` namespace may not be recognized. You will need to create an assembly definition to use the `PubNubAPI` in your application.
32+
1. Navigate to the Assets > PubNub folder in the Project window.
33+
2. Right-click the PubNub folder and create an [Assembly Definition](https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html) by selecting Create > Assembly Definition. Assign a name to the asset (such as PubNub) and leave the default settings.
34+
3. Navigate to the folder that you wish to use the `PubNubAPI` namespace. Click on the Assembly Definition file.
35+
4. In the Inspector window, add the **PubNub** Assembly Definition you created earlier to the list of Assembly Definition References section by clicking on the **+** icon.
36+
5. Scroll down in the Inspector window, and click Apply. The `PubNubAPI` namespace should now be visible in your application.
37+
6. You may receive more compiler errors when trying to use the `PubNubAPI` namespace. These come from the PubNub > Editor folder, and contain test files. Delete the entire PubNub > Editor folder and allow the Unity editor to recompile changes.
38+
3039
## Add event listeners
3140

3241
```csharp
3342
pubnub.SubscribeCallback += SubscribeCallbackHandler;
3443

3544
//Handler
3645
void SubscribeCallbackHandler(object sender, EventArgs e) {
37-
SubscribeEventEventArgs mea = e as SubscribeEventEventArgs;
38-
39-
if (mea.Status != null) {
40-
switch (mea.Status.Category) {
41-
case PNStatusCategory.PNUnexpectedDisconnectCategory:
42-
case PNStatusCategory.PNTimeoutCategory:
43-
// handle publish
44-
break;
45-
}
46-
}
47-
if (mea.MessageResult != null) {
48-
Debug.Log("Channel" + mea.MessageResult.Channel);
49-
Debug.Log("Payload" + mea.MessageResult.Payload);
50-
Debug.Log("Publisher Id: " + mea.MessageResult.IssuingClientId);
51-
}
52-
if (mea.PresenceEventResult != null) {
53-
Debug.Log("SubscribeCallback in presence" + mea.PresenceEventResult.Channel + mea.PresenceEventResult.Occupancy + mea.PresenceEventResult.Event);
54-
}
55-
if (mea.SignalEventResult != null) {
56-
Debug.Log ("SubscribeCallback in SignalEventResult" + mea.SignalEventResult.Channel + mea.SignalEventResult.Payload);
57-
}
58-
if (mea.UserEventResult != null) {
59-
Debug.Log(mea.UserEventResult.Name);
60-
Debug.Log(mea.UserEventResult.Email);
61-
Debug.Log(mea.UserEventResult.ExternalID);
62-
Debug.Log(mea.UserEventResult.ProfileURL);
63-
Debug.Log(mea.UserEventResult.UserID);
64-
Debug.Log(mea.UserEventResult.ETag);
65-
Debug.Log(mea.UserEventResult.ObjectsEvent);
66-
}
67-
if (mea.SpaceEventResult != null) {
68-
Debug.Log(mea.SpaceEventResult.Name);
69-
Debug.Log(mea.SpaceEventResult.Description);
70-
Debug.Log(mea.SpaceEventResult.SpaceID);
71-
Debug.Log(mea.SpaceEventResult.ETag);
72-
Debug.Log(mea.SpaceEventResult.ObjectsEvent);
73-
}
74-
if (mea.MembershipEventResult != null) {
75-
Debug.Log(mea.MembershipEventResult.UserID);
76-
Debug.Log(mea.MembershipEventResult.Description);
77-
Debug.Log(mea.MembershipEventResult.SpaceID);
78-
Debug.Log(mea.MembershipEventResult.ObjectsEvent);
79-
}
80-
if (mea.MessageActionsEventResult != null) {
81-
Debug.Log(mea.MessageActionsEventResult.Channel);
82-
if(mea.MessageActionsEventResult.Data!=null){
83-
Debug.Log(mea.MessageActionsEventResult.Data.ActionTimetoken);
84-
Debug.Log(mea.MessageActionsEventResult.Data.ActionType);
85-
Debug.Log(mea.MessageActionsEventResult.Data.ActionValue);
86-
Debug.Log(mea.MessageActionsEventResult.Data.MessageTimetoken);
87-
Debug.Log(mea.MessageActionsEventResult.Data.UUID);
88-
}
89-
Debug.Log(mea.MessageActionsEventResult.MessageActionsEvent);
90-
Debug.Log(mea.MessageActionsEventResult.Subscription);
91-
}
46+
SubscribeEventEventArgs mea = e as SubscribeEventEventArgs;
47+
48+
if (mea.Status != null) {
49+
switch (mea.Status.Category) {
50+
case PNStatusCategory.PNUnexpectedDisconnectCategory:
51+
case PNStatusCategory.PNTimeoutCategory:
52+
// handle publish
53+
break;
54+
}
55+
}
56+
if (mea.MessageResult != null) {
57+
Debug.Log("Channel" + mea.MessageResult.Channel);
58+
Debug.Log("Payload" + mea.MessageResult.Payload);
59+
Debug.Log("Publisher Id: " + mea.MessageResult.IssuingClientId);
60+
}
61+
if (mea.PresenceEventResult != null) {
62+
Debug.Log("SubscribeCallback in presence" + mea.PresenceEventResult.Channel + mea.PresenceEventResult.Occupancy + mea.PresenceEventResult.Event);
63+
}
64+
if (mea.SignalEventResult != null) {
65+
Debug.Log ("SubscribeCallback in SignalEventResult" + mea.SignalEventResult.Channel + mea.SignalEventResult.Payload);
66+
}
67+
if (mea.UUIDEventResult != null) {
68+
Debug.Log(mea.UUIDEventResult.Name);
69+
Debug.Log(mea.UUIDEventResult.Email);
70+
Debug.Log(mea.UUIDEventResult.ExternalID);
71+
Debug.Log(mea.UUIDEventResult.ProfileURL);
72+
Debug.Log(mea.UUIDEventResult.UUID);
73+
Debug.Log(mea.UUIDEventResult.ETag);
74+
Debug.Log(mea.UUIDEventResult.ObjectsEvent);
75+
}
76+
if (mea.ChannelEventResult != null) {
77+
Debug.Log(mea.ChannelEventResult.Name);
78+
Debug.Log(mea.ChannelEventResult.Description);
79+
Debug.Log(mea.ChannelEventResult.ChannelID);
80+
Debug.Log(mea.ChannelEventResult.ETag);
81+
Debug.Log(mea.ChannelEventResult.ObjectsEvent);
82+
}
83+
if (mea.MembershipEventResult != null) {
84+
Debug.Log(mea.MembershipEventResult.UUID);
85+
Debug.Log(mea.MembershipEventResult.Description);
86+
Debug.Log(mea.MembershipEventResult.ChannelID);
87+
Debug.Log(mea.MembershipEventResult.ObjectsEvent);
88+
}
89+
if (mea.MessageActionsEventResult != null) {
90+
Debug.Log(mea.MessageActionsEventResult.Channel);
91+
if(mea.MessageActionsEventResult.Data!=null){
92+
Debug.Log(mea.MessageActionsEventResult.Data.ActionTimetoken);
93+
Debug.Log(mea.MessageActionsEventResult.Data.ActionType);
94+
Debug.Log(mea.MessageActionsEventResult.Data.ActionValue);
95+
Debug.Log(mea.MessageActionsEventResult.Data.MessageTimetoken);
96+
Debug.Log(mea.MessageActionsEventResult.Data.UUID);
97+
}
98+
Debug.Log(mea.MessageActionsEventResult.MessageActionsEvent);
99+
Debug.Log(mea.MessageActionsEventResult.Subscription);
100+
}
92101
}
93102
```
94103

@@ -98,7 +107,7 @@ void SubscribeCallbackHandler(object sender, EventArgs e) {
98107
pubnub.Publish()
99108
.Channel("channel1")
100109
.Message("test message")
101-
.Async((result, status) => {
110+
.Async((result, status) => {
102111
if (!status.Error) {
103112
Debug.Log(string.Format("Publish Timetoken: {0}", result.Timetoken));
104113
} else {
@@ -116,9 +125,8 @@ pubnub.Subscribe()
116125

117126
## Documentation
118127

119-
* [Build your first realtime Unity app with PubNub](https://www.pubnub.com/docs/platform/quickstarts/unity)
120-
* [API reference for Unity](https://www.pubnub.com/docs/unity3d-c-sharp/pubnub-c-sharp-sdk)
128+
* [API reference for Unity](https://www.pubnub.com/docs/sdks/unity)
121129
122130
## Support
123131

124-
If you **need help** or have a **general question**, contact [email protected].
132+
If you **need help** or have a **general question**, contact support@pubnub.com.

0 commit comments

Comments
 (0)