@@ -87,7 +87,6 @@ void ButtonUnsubscribeAllHandler(){
87
87
}
88
88
void ButtonDeleteHistoryHandler ( ) {
89
89
pubnub . DeleteMessages ( ) . Channel ( "channel1" ) . Start ( 15078932998876451 ) . End ( 15078933628583256 ) . Async ( ( result , status ) => {
90
- //pubnub.DeleteMessages().Channel("channel1").Async((result, status) => {
91
90
Debug . Log ( "in DeleteMessages" ) ;
92
91
if ( ! status . Error ) {
93
92
Debug . Log ( string . Format ( "DateTime {0}, In DeleteMessages Example, Timetoken: {1}" , DateTime . UtcNow , result . Message ) ) ;
@@ -306,6 +305,15 @@ void ButtonAddPushNotificationsOnChannelsHandler(){
306
305
Display ( string . Format ( "AddPushNotificationsOnChannels: {0}" , result . Message ) ) ;
307
306
}
308
307
} ) ;
308
+ pubnub . AddPushNotificationsOnChannels ( ) . Channels ( listChannels ) . DeviceID ( deviceId ) . PushType ( PNPushType . APNS2 ) . Topic ( "a" ) . Async ( ( result , status ) => {
309
+ Debug . Log ( "in AddPushNotificationsOnChannels" ) ;
310
+ if ( status . Error ) {
311
+ Debug . Log ( string . Format ( "In Example, AddPushNotificationsOnChannels Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
312
+ } else {
313
+ Debug . Log ( string . Format ( "DateTime {0}, In AddPushNotificationsOnChannels, result: {1}" , DateTime . UtcNow , result . Message ) ) ;
314
+ Display ( string . Format ( "AddPushNotificationsOnChannels: {0}" , result . Message ) ) ;
315
+ }
316
+ } ) ;
309
317
}
310
318
void ButtonAuditPushChannelProvisionsHandler ( ) {
311
319
AuditPushChannelProvisions ( pubnub , deviceId , pnPushType ) ;
@@ -434,7 +442,6 @@ void Init(){
434
442
}
435
443
436
444
void MessageCounts ( List < string > listChannels , PubNub pubnub ) {
437
- //pubnub.MessageCounts().ChannelTimetokens(new List<string>{"15499825804610610","15499925804610615"}).Channels(listChannels).Timetoken("1549982652").Async((result, status) =>{
438
445
pubnub . MessageCounts ( ) . Channels ( listChannels ) . ChannelsTimetoken ( new List < long > { 1549982652 } ) . Async ( ( result , status ) => {
439
446
if ( status . Error ) {
440
447
Debug . Log ( string . Format ( "In Example, MessageCounts Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
@@ -515,11 +522,10 @@ void DisplayMessages(Dictionary<string, object> message, string channel) {
515
522
void FetchRecursive ( long start , List < string > listChannels ) {
516
523
517
524
pubnub . FetchMessages ( ) . Channels ( listChannels ) . Start ( start ) . Async ( ( result , status ) => {
518
- //pubnub.FetchMessages().Channels(new List<string>{"channel2"}).Async ((result, status) => {
519
525
if ( status . Error ) {
520
526
Debug . Log ( string . Format ( "In Example, FetchMessages Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
521
527
} else {
522
- Debug . Log ( string . Format ( "In FetchMessages, result: " ) ) ; //,result.EndTimetoken, result.Messages[0].ToString()));
528
+ Debug . Log ( string . Format ( "In FetchMessages, result: " ) ) ;
523
529
foreach ( KeyValuePair < string , List < PNMessageResult > > kvp in result . Channels ) {
524
530
Debug . Log ( "kvp channelname" + kvp . Key ) ;
525
531
foreach ( PNMessageResult pnMessageResut in kvp . Value ) {
@@ -550,8 +556,6 @@ void GetHistoryRecursive(long start, string channel){
550
556
} ) ;
551
557
}
552
558
553
-
554
-
555
559
void SubscribeCallbackHandler ( object sender , EventArgs e ) {
556
560
Debug . Log ( "SubscribeCallbackHandler Event handler" ) ;
557
561
SubscribeEventEventArgs mea = e as SubscribeEventEventArgs ;
@@ -582,8 +586,6 @@ void SubscribeCallbackHandler(object sender, EventArgs e){
582
586
}
583
587
if ( mea . MessageResult != null ) {
584
588
Debug . Log ( "In Example, SubscribeCallback in message" + mea . MessageResult . Channel + mea . MessageResult . Payload ) ;
585
- //var a = mea.MessageResult.Payload as Dictionary<string, string>;
586
- //var b = a["a"];
587
589
Display ( string . Format ( "SubscribeCallback Result: {0}" , pubnub . JsonLibrary . SerializeToJsonString ( mea . MessageResult . Payload ) ) ) ;
588
590
}
589
591
if ( mea . PresenceEventResult != null ) {
@@ -605,6 +607,16 @@ void RemoveChannelsFromPush(List<string> listChannels, PubNub pubnub, string dev
605
607
Display ( string . Format ( "RemovePushNotificationsFromChannels: {0}" , result . Message ) ) ;
606
608
}
607
609
} ) ;
610
+ pubnub . RemovePushNotificationsFromChannels ( ) . Channels ( listChannels ) . DeviceID ( deviceId ) . PushType ( PNPushType . APNS2 ) . Topic ( "a" ) . Async ( ( result , status ) => {
611
+ Debug . Log ( "in RemovePushNotificationsFromChannels" ) ;
612
+ if ( status . Error ) {
613
+ Debug . Log ( string . Format ( "In Example, RemovePushNotificationsFromChannels Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
614
+ } else {
615
+ Debug . Log ( string . Format ( "DateTime {0}, In RemovePushNotificationsFromChannels, result: {1}" , DateTime . UtcNow , result . Message ) ) ;
616
+ Display ( string . Format ( "RemovePushNotificationsFromChannels: {0}" , result . Message ) ) ;
617
+ }
618
+ } ) ;
619
+
608
620
}
609
621
610
622
void AuditPushChannelProvisions ( PubNub pubnub , string deviceId , PNPushType pnPushType ) {
@@ -618,6 +630,17 @@ void AuditPushChannelProvisions(PubNub pubnub, string deviceId, PNPushType pnPus
618
630
}
619
631
620
632
} ) ;
633
+ pubnub . AuditPushChannelProvisions ( ) . DeviceID ( deviceId ) . PushType ( pnPushType ) . PushType ( PNPushType . APNS2 ) . Topic ( "a" ) . Async ( ( result , status ) => {
634
+ Debug . Log ( "in AuditPushChannelProvisions" ) ;
635
+ if ( status . Error ) {
636
+ Debug . Log ( string . Format ( "In Example, AuditPushChannelProvisions Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
637
+ } else {
638
+ Debug . Log ( string . Format ( "DateTime {0}, In AuditPushChannelProvisions, result: {1}" , DateTime . UtcNow , ( result . Channels != null ) ? string . Join ( "," , result . Channels . ToArray ( ) ) : "" ) ) ;
639
+ Display ( string . Format ( "AuditPushChannelProvisions: {0}" , ( result . Channels != null ) ? string . Join ( "," , result . Channels . ToArray ( ) ) : "" ) ) ;
640
+ }
641
+
642
+ } ) ;
643
+
621
644
}
622
645
623
646
void RemoveAllPushNotificationsFromChannels ( PubNub pubnub , string deviceId , PNPushType pnPushType ) {
@@ -631,6 +654,17 @@ void RemoveAllPushNotificationsFromChannels(PubNub pubnub, string deviceId, PNPu
631
654
}
632
655
633
656
} ) ;
657
+ pubnub . RemoveAllPushNotifications ( ) . DeviceID ( deviceId ) . PushType ( PNPushType . APNS2 ) . Topic ( "a" ) . Async ( ( result , status ) => {
658
+ Debug . Log ( "in RemoveAllPushNotificationsFromChannels" ) ;
659
+ if ( status . Error ) {
660
+ Debug . Log ( string . Format ( "In Example, RemoveAllPushNotificationsFromChannels Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
661
+ } else {
662
+ Debug . Log ( string . Format ( "DateTime {0}, In RemoveAllPushNotificationsFromChannels, result: {1}" , DateTime . UtcNow , result . Message ) ) ;
663
+ Display ( string . Format ( "RemoveAllPushNotificationsFromChannels: {0}" , result . Message ) ) ;
664
+ }
665
+
666
+ } ) ;
667
+
634
668
}
635
669
636
670
void RemoveChannelsFromCG ( PubNub pubnub , string cg , List < string > listChannelsRemove ) {
@@ -660,7 +694,6 @@ void ListAllChannelsOfGroup(PubNub pubnub, string cg){
660
694
661
695
void FetchMessages ( PubNub pubnub , List < string > listChannels ) {
662
696
pubnub . FetchMessages ( ) . Channels ( listChannels ) . IncludeMeta ( true ) . Async ( ( result , status ) => {
663
- //pubnub.FetchMessages().Channels(new List<string>{"channel2"}).Async ((result, status) => {
664
697
if ( status . Error ) {
665
698
Debug . Log ( string . Format ( "In Example, FetchMessages Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
666
699
} else {
@@ -745,22 +778,14 @@ void PrintStatus(PNStatus s){
745
778
( s . ClientRequest != null ) ? s . ClientRequest . ToString ( ) : "null"
746
779
) ) ;
747
780
748
- //Display (s.Category.ToString());
749
781
}
750
782
}
751
783
752
784
void Display ( string textToDisplay ) {
753
785
TextContent . text = string . Format ( "{0}\n {1}" , TextContent . text , textToDisplay ) ;
754
- //UnityEngine.UI.Text txtRef = (UnityEngine.UI.Text)GameObject.Find("CountText").GetComponent<Text>;
755
- //Debug.Log("TextContent.text 2:" + TextContent.text);
756
- //TextScroll
757
- //Canvas.
758
- //Debug.Log("transform:" + transform.Find("TextContent").name);
759
786
}
760
787
761
- //public string stringToEdit = "Hello World";
762
788
void OnGUI ( ) {
763
- //stringToEdit = GUI.TextField(new Rect(10, 10, 600, 600), stringToEdit, 600);
764
789
765
790
}
766
791
0 commit comments