@@ -2839,6 +2839,142 @@ public IEnumerator TestCGRemove() {
28392839
28402840 }
28412841
2842+ [ UnityTest ]
2843+ public IEnumerator TestPushAPNS2 ( ) {
2844+ return TestPushCommon ( PNPushType . APNS2 ) ;
2845+ }
2846+
2847+ [ UnityTest ]
2848+ public IEnumerator TestPushGCM ( ) {
2849+ return TestPushCommon ( PNPushType . GCM ) ;
2850+ }
2851+
2852+ public IEnumerator TestPushCommon ( PNPushType pnPushType ) {
2853+ PNConfiguration pnConfiguration = PlayModeCommon . SetPNConfig ( false ) ;
2854+ PubNub pubnub = new PubNub ( pnConfiguration ) ;
2855+ System . Random r = new System . Random ( ) ;
2856+ pnConfiguration . UUID = "UnityTestCGUUID_" + r . Next ( 100 ) ;
2857+ string channel = "UnityTestWithPushChannel" ;
2858+ string channel2 = "UnityTestWithPushChannel2" ;
2859+ List < string > listChannels = new List < string > ( ) ;
2860+ listChannels . Add ( channel ) ;
2861+ listChannels . Add ( channel2 ) ;
2862+
2863+ string deviceId = "ababababababababababababababababababababababababababababababababababababababababababababab" ;
2864+ bool tresult = false ;
2865+
2866+ // AddPushNotificationsOnChannels
2867+ if ( pnPushType . Equals ( PNPushType . APNS2 ) ) {
2868+ pubnub . AddPushNotificationsOnChannels ( ) . Channels ( listChannels ) . DeviceID ( deviceId ) . PushType ( pnPushType ) . Topic ( "a" ) . Async ( ( result , status ) => {
2869+ Debug . Log ( "in AddPushNotificationsOnChannels" ) ;
2870+ if ( status . Error ) {
2871+ Debug . Log ( string . Format ( "In Example, AddPushNotificationsOnChannels Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
2872+ } else {
2873+ tresult = result . Message . Contains ( "Modified Channels" ) ;
2874+ Debug . Log ( string . Format ( "DateTime {0}, In AddPushNotificationsOnChannels, result: {1}" , DateTime . UtcNow , result . Message ) ) ;
2875+ }
2876+
2877+ } ) ;
2878+ } else {
2879+ pubnub . AddPushNotificationsOnChannels ( ) . Channels ( listChannels ) . DeviceID ( deviceId ) . PushType ( pnPushType ) . Async ( ( result , status ) => {
2880+ Debug . Log ( "in AddPushNotificationsOnChannels" ) ;
2881+ if ( status . Error ) {
2882+ Debug . Log ( string . Format ( "In Example, AddPushNotificationsOnChannels Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
2883+ } else {
2884+ tresult = result . Message . Contains ( "Modified Channels" ) ;
2885+ Debug . Log ( string . Format ( "DateTime {0}, In AddPushNotificationsOnChannels, result: {1}" , DateTime . UtcNow , result . Message ) ) ;
2886+ }
2887+ } ) ;
2888+ }
2889+ yield return new WaitForSeconds ( PlayModeCommon . WaitTimeBetweenCalls2 ) ;
2890+ Assert . True ( tresult , "AddPushNotificationsOnChannels didn't return" ) ;
2891+ tresult = false ;
2892+
2893+ // AuditPushChannelProvisions
2894+ if ( pnPushType . Equals ( PNPushType . APNS2 ) ) {
2895+ pubnub . AuditPushChannelProvisions ( ) . DeviceID ( deviceId ) . PushType ( pnPushType ) . Topic ( "a" ) . Async ( ( result , status ) => {
2896+ Debug . Log ( "in AuditPushChannelProvisions" ) ;
2897+ if ( status . Error ) {
2898+ Debug . Log ( string . Format ( "In Example, AuditPushChannelProvisions Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
2899+ } else {
2900+ tresult = true ;
2901+ Debug . Log ( string . Format ( "DateTime {0}, In AuditPushChannelProvisions, result: {1}" , DateTime . UtcNow , result ) ) ;
2902+ }
2903+ } ) ;
2904+ } else {
2905+ pubnub . AuditPushChannelProvisions ( ) . DeviceID ( deviceId ) . PushType ( pnPushType ) . Async ( ( result , status ) => {
2906+ Debug . Log ( "in AuditPushChannelProvisions" ) ;
2907+ if ( status . Error ) {
2908+ Debug . Log ( string . Format ( "In Example, AuditPushChannelProvisions Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
2909+ } else {
2910+ tresult = true ;
2911+ Debug . Log ( string . Format ( "DateTime {0}, In AuditPushChannelProvisions, result: {1}" , DateTime . UtcNow , result ) ) ;
2912+ }
2913+
2914+ } ) ;
2915+ }
2916+ yield return new WaitForSeconds ( PlayModeCommon . WaitTimeBetweenCalls2 ) ;
2917+ Assert . True ( tresult , "AuditPushChannelProvisions didn't return" ) ;
2918+ tresult = false ;
2919+
2920+ // RemovePushNotificationsFromChannels
2921+ if ( pnPushType . Equals ( PNPushType . APNS2 ) ) {
2922+ pubnub . RemovePushNotificationsFromChannels ( ) . Channels ( new List < string > { channel } ) . DeviceID ( deviceId ) . PushType ( pnPushType ) . Topic ( "a" ) . Async ( ( result , status ) => {
2923+ Debug . Log ( "in RemovePushNotificationsFromChannels" ) ;
2924+ if ( status . Error ) {
2925+ Debug . Log ( string . Format ( "In Example, RemovePushNotificationsFromChannels Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
2926+ } else {
2927+ tresult = result . Message . Contains ( "Modified Channels" ) ;
2928+ Debug . Log ( string . Format ( "DateTime {0}, In RemovePushNotificationsFromChannels, result: {1}" , DateTime . UtcNow , result . Message ) ) ;
2929+ }
2930+
2931+ } ) ;
2932+ } else {
2933+ pubnub . RemovePushNotificationsFromChannels ( ) . Channels ( new List < string > { channel } ) . DeviceID ( deviceId ) . PushType ( pnPushType ) . Async ( ( result , status ) => {
2934+ Debug . Log ( "in RemovePushNotificationsFromChannels" ) ;
2935+ if ( status . Error ) {
2936+ Debug . Log ( string . Format ( "In Example, RemovePushNotificationsFromChannels Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
2937+ } else {
2938+ tresult = result . Message . Contains ( "Modified Channels" ) ;
2939+ Debug . Log ( string . Format ( "DateTime {0}, In RemovePushNotificationsFromChannels, result: {1}" , DateTime . UtcNow , result . Message ) ) ;
2940+ }
2941+
2942+ } ) ;
2943+ }
2944+ yield return new WaitForSeconds ( PlayModeCommon . WaitTimeBetweenCalls2 ) ;
2945+ Assert . True ( tresult , "RemovePushNotificationsFromChannels didn't return" ) ;
2946+ tresult = false ;
2947+
2948+ // RemoveAllPushNotifications
2949+ if ( pnPushType . Equals ( PNPushType . APNS2 ) ) {
2950+ pubnub . RemoveAllPushNotifications ( ) . DeviceID ( deviceId ) . PushType ( pnPushType ) . Topic ( "a" ) . Async ( ( result , status ) => {
2951+ Debug . Log ( "in RemoveAllPushNotifications" ) ;
2952+ if ( status . Error ) {
2953+ Debug . Log ( string . Format ( "In Example, RemoveAllPushNotifications Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
2954+ } else {
2955+ tresult = result . Message . Contains ( "Removed Device" ) ;
2956+ Debug . Log ( string . Format ( "DateTime {0}, In RemoveAllPushNotifications, result: {1}" , DateTime . UtcNow , result . Message ) ) ;
2957+ }
2958+
2959+ } ) ;
2960+ } else {
2961+ pubnub . RemoveAllPushNotifications ( ) . DeviceID ( deviceId ) . PushType ( pnPushType ) . Async ( ( result , status ) => {
2962+ Debug . Log ( "in RemoveAllPushNotifications" ) ;
2963+ if ( status . Error ) {
2964+ Debug . Log ( string . Format ( "In Example, RemoveAllPushNotifications Error: {0} {1} {2}" , status . StatusCode , status . ErrorData , status . Category ) ) ;
2965+ } else {
2966+ tresult = result . Message . Contains ( "Removed Device" ) ;
2967+ Debug . Log ( string . Format ( "DateTime {0}, In RemoveAllPushNotifications, result: {1}" , DateTime . UtcNow , result . Message ) ) ;
2968+ }
2969+
2970+ } ) ;
2971+ }
2972+ yield return new WaitForSeconds ( PlayModeCommon . WaitTimeBetweenCalls2 ) ;
2973+ Assert . True ( tresult , "RemoveAllPushNotifications didn't return" ) ;
2974+ tresult = false ;
2975+
2976+ }
2977+
28422978 //[UnityTest]
28432979 // public IEnumerator TestPush() {
28442980 // PNConfiguration pnConfiguration = PlayModeCommon.SetPNConfig(false);
0 commit comments