Skip to content

Commit 0f4a08f

Browse files
authored
Merge pull request #33 from pubnub/feature/APNS2-CE-4222
APNS2 and CreatePushPayloadHelper
2 parents 8488578 + c6f1142 commit 0f4a08f

23 files changed

+1560
-28
lines changed

.pubnub.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
---
22
changelog:
3+
-
4+
changes:
5+
-
6+
text: "APNS2"
7+
type: improvement
8+
-
9+
text: "Push payload helper class"
10+
type: improvement
11+
date: Dec 24, 19
12+
version: v4.7.0
313
-
414
changes:
515
-
@@ -359,6 +369,7 @@ features:
359369
others:
360370
- TELEMETRY
361371
- QUERY-PARAM
372+
- CREATE-PUSH-PAYLOAD
362373
presence:
363374
- PRESENCE-HERE-NOW
364375
- PRESENCE-WHERE-NOW
@@ -381,6 +392,10 @@ features:
381392
- PUSH-REMOVE-DEVICE-FROM-CHANNELS
382393
- PUSH-LIST-CHANNELS-FROM-DEVICE
383394
- PUSH-REMOVE-DEVICE
395+
- PUSH-TYPE-APNS
396+
- PUSH-TYPE-APNS2
397+
- PUSH-TYPE-FCM
398+
- PUSH-TYPE-MPNS
384399
storage:
385400
- STORAGE-REVERSE
386401
- STORAGE-INCLUDE-TIMETOKEN
@@ -452,4 +467,4 @@ supported-platforms:
452467
- "Ubuntu 12.04+, with Graphics card DX9 (shader model 3.0) or DX11 with feature level 9.3 capabilities; and CPU SSE2 instruction set support."
453468
- "Mac OS X 10.8+, with Graphics card DX9 (shader model 3.0) or DX11 with feature level 9.3 capabilities; and CPU SSE2 instruction set support."
454469
version: "PubNub Unity SDK"
455-
version: v4.6.0
470+
version: v4.7.0

PubNubUnity/Assets/PubNub/Builders/Push/AddChannelsToPushRequestBuilder.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ public class AddChannelsToPushRequestBuilder: PubNubNonSubBuilder<AddChannelsToP
1010
public AddChannelsToPushRequestBuilder(PubNubUnity pn):base(pn, PNOperationType.PNAddPushNotificationsOnChannelsOperation){
1111
}
1212
private string DeviceIDForPush{ get; set;}
13+
private string TopicForPush{ get; set;}
14+
private PNPushEnvironment EnvironmentForPush{ get; set;}
15+
public void Topic(string topic){
16+
TopicForPush = topic;
17+
}
18+
19+
public void Environment(PNPushEnvironment environment){
20+
EnvironmentForPush = environment;
21+
}
22+
1323
public void Channels(List<string> channelNames){
1424
ChannelsToUse = channelNames;
1525
}
@@ -45,6 +55,14 @@ public void Async(Action<PNPushAddChannelResult, PNStatus> callback)
4555
#endif
4656
PushType = PNPushType.GCM;
4757
}
58+
59+
if (PushType.Equals(PNPushType.APNS2) && (string.IsNullOrEmpty(TopicForPush))) {
60+
PNStatus pnStatus = base.CreateErrorResponseFromMessage(CommonText.APNS2TopicEmpty, null, PNStatusCategory.PNBadRequestCategory);
61+
Callback(null, pnStatus);
62+
63+
return;
64+
}
65+
4866
base.Async(this);
4967
}
5068
#endregion

PubNubUnity/Assets/PubNub/Builders/Push/ListPushProvisionsRequestBuilder.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ public class ListPushProvisionsRequestBuilder: PubNubNonSubBuilder<ListPushProvi
99
{
1010
public ListPushProvisionsRequestBuilder(PubNubUnity pn):base(pn, PNOperationType.PNPushNotificationEnabledChannelsOperation){
1111
}
12-
12+
private string TopicForPush{ get; set;}
13+
private PNPushEnvironment EnvironmentForPush{ get; set;}
14+
public void Topic(string topic){
15+
TopicForPush = topic;
16+
}
17+
public void Environment(PNPushEnvironment environment){
18+
EnvironmentForPush = environment;
19+
}
1320
private string DeviceIDForPush{ get; set;}
1421

1522
public void DeviceId(string deviceIdToPush){
@@ -36,6 +43,14 @@ public void Async(Action<PNPushListProvisionsResult, PNStatus> callback)
3643
#endif
3744
PushType = PNPushType.GCM;
3845
}
46+
47+
if (PushType.Equals(PNPushType.APNS2) && (string.IsNullOrEmpty(TopicForPush))) {
48+
PNStatus pnStatus = base.CreateErrorResponseFromMessage(CommonText.APNS2TopicEmpty, null, PNStatusCategory.PNBadRequestCategory);
49+
Callback(null, pnStatus);
50+
51+
return;
52+
}
53+
3954
base.Async(this);
4055
}
4156
#endregion

PubNubUnity/Assets/PubNub/Builders/Push/RemoveAllPushChannelsForDeviceRequestBuilder.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ public class RemoveAllPushChannelsForDeviceRequestBuilder: PubNubNonSubBuilder<R
99
{
1010
public RemoveAllPushChannelsForDeviceRequestBuilder(PubNubUnity pn):base(pn, PNOperationType.PNRemoveAllPushNotificationsOperation){
1111
}
12+
private string TopicForPush{ get; set;}
13+
private PNPushEnvironment EnvironmentForPush{ get; set;}
14+
public void Topic(string topic){
15+
TopicForPush = topic;
16+
}
1217

18+
public void Environment(PNPushEnvironment environment){
19+
EnvironmentForPush = environment;
20+
}
1321
private string DeviceIDForPush{ get; set;}
1422

1523
public void DeviceId(string deviceIdForPush){
@@ -36,6 +44,14 @@ public void Async(Action<PNPushRemoveAllChannelsResult, PNStatus> callback)
3644
#endif
3745
PushType = PNPushType.GCM;
3846
}
47+
48+
if (PushType.Equals(PNPushType.APNS2) && (string.IsNullOrEmpty(TopicForPush))) {
49+
PNStatus pnStatus = base.CreateErrorResponseFromMessage(CommonText.APNS2TopicEmpty, null, PNStatusCategory.PNBadRequestCategory);
50+
Callback(null, pnStatus);
51+
52+
return;
53+
}
54+
3955
base.Async(this);
4056
}
4157
#endregion

PubNubUnity/Assets/PubNub/Builders/Push/RemoveChannelsFromPushRequestBuilder.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ public class RemoveChannelsFromPushRequestBuilder: PubNubNonSubBuilder<RemoveCha
1010
public RemoveChannelsFromPushRequestBuilder(PubNubUnity pn):base(pn, PNOperationType.PNRemovePushNotificationsFromChannelsOperation){
1111

1212
}
13+
private string TopicForPush{ get; set;}
14+
private PNPushEnvironment EnvironmentForPush{ get; set;}
15+
public void Topic(string topic){
16+
TopicForPush = topic;
17+
}
1318

19+
public void Environment(PNPushEnvironment environment){
20+
EnvironmentForPush = environment;
21+
}
1422
private string DeviceIDForPush{ get; set;}
1523
public void Channels(List<string> channelNames){
1624
ChannelsToUse = channelNames;
@@ -41,6 +49,13 @@ public void Async(Action<PNPushRemoveChannelResult, PNStatus> callback)
4149
return;
4250
}
4351

52+
if (PushType.Equals(PNPushType.APNS2) && (string.IsNullOrEmpty(TopicForPush))) {
53+
PNStatus pnStatus = base.CreateErrorResponseFromMessage(CommonText.APNS2TopicEmpty, null, PNStatusCategory.PNBadRequestCategory);
54+
Callback(null, pnStatus);
55+
56+
return;
57+
}
58+
4459
base.Async(this);
4560
}
4661
#endregion

0 commit comments

Comments
 (0)