@@ -165,6 +165,13 @@ - (void)setupClientLogger;
165165 */
166166- (void )printLogVerbosityInformation ;
167167
168+ /* *
169+ @brief Check client configuration and notify about outdated API and options.
170+
171+ @since 4.5.13
172+ */
173+ - (void )notifyDeprecatedAPI ;
174+
168175#pragma mark -
169176
170177
@@ -235,6 +242,7 @@ - (instancetype)initWithConfiguration:(PNConfiguration *)configuration
235242 _instanceID = [@" 58EB05C9-9DE4-4118-B5D7-EE059FBF19A9" copy ];
236243 }
237244 [self prepareNetworkManagers ];
245+ [self notifyDeprecatedAPI ];
238246
239247 _subscriberManager = [PNSubscriber subscriberForClient: self ];
240248 _sequenceManager = [PNPublishSequence sequenceForClient: self ];
@@ -601,6 +609,57 @@ - (void)printLogVerbosityInformation {
601609 [enabledFlags componentsJoinedByString: @" , " ]);
602610}
603611
612+ - (void )notifyDeprecatedAPI {
613+
614+ NSMutableString *deprecation = [NSMutableString new ];
615+ [deprecation appendString: @" \n\n\n --------------------------------------------\n - PubNub deprecated API "
616+ " usage notification -\n --------------------------------------------\n\n " ];
617+ if (self.configuration .shouldStripMobilePayload ) {
618+
619+ [deprecation appendString: @" - Deprecated: PNConfiguration.shouldStripMobilePayload property.-\n "
620+ " When set to YES SDK automatically stripped out original message\n frompayload which combined message"
621+ " and push notification payloads.\n\n This deprecation may affect application in case if it "
622+ " used\n publish API to send messages along with push notification payloads.\n Property completely will"
623+ " be deprecated with next 'major' SDK update.\n\n " ];
624+
625+ [deprecation appendString: @" If application's code rely on automatic messages clean up (send\n mobile "
626+ " push notifications along with messages or store message\n inside payload) it is suggested to update "
627+ " this code before property\n will be completely removed from SDK.\n At first "
628+ " `shouldStripMobilePayload` should be set to NO (YES by\n default). Next will be update callback "
629+ " which handle new messages:\n\n "
630+ " \t - (void)client:(PubNub *)client didReceiveMessage:(PNMessageResult *)message {\n\n "
631+ " \t\t id messageData = message.data.message;\n "
632+ " \t\t if ([messageData isKindOfClass:[NSDictionary class]]) {\n\n "
633+ " \t\t\t // It will be better to access cipher key directly, because 'currentConfiguration'\n "
634+ " \t\t\t // make copy of PNConfiguration each time.\n "
635+ " \t\t\t NSString *cipherKey = [client currentConfiguration].cipherKey;\n "
636+ " \t\t\t NSMutableDictionary *messagePayload = [messageData mutableCopy];\n "
637+ " \t\t\t if (cipherKey.length && messagePayload[@\" pn_other\" ]) {\n\n "
638+ " \t\t\t\t NSError *parseError = nil;\n "
639+ " \t\t\t\t id decryptedMessageData = [PNAES decrypt:messagePayload[@\" pn_other\" ] withKey:cipherKey \n "
640+ " \t\t\t\t andError:&parseError];\n "
641+ " \t\t\t\t if (decryptedMessageData) {\n\n "
642+ " \t\t\t\t\t messageData = [NSJSONSerialization JSONObjectWithData:decryptedMessageData\n "
643+ " \t\t\t\t\t options:NSJSONReadingAllowFragments\n "
644+ " \t\t\t\t\t error:&parseError];\n "
645+ " \t\t\t\t }\n "
646+ " \t\t\t\t if (!parseError) {\n\n "
647+ " \t\t\t\t\t if (![messageData isKindOfClass:[NSDictionary class]]) {\n\n "
648+ " \t\t\t\t\t\t messagePayload[@\" pn_other\" ] = messageData;\n "
649+ " \t\t\t\t\t } else { [messagePayload addEntriesFromDictionary:messageData]; }\n "
650+ " \t\t\t\t }\n "
651+ " \t\t\t\t else { /* Handle message decryption and JSON decode. */ }\n "
652+ " \t\t\t }\n "
653+ " \t\t\t // Remove keys for any used push notification provider.\n "
654+ " \t\t\t [messagePayload removeObjectsForKeys:@[@\" pn_apns\" , @\" pn_gcm\" , @\" pn_mpns\" ]];\n "
655+ " \t\t\t messageData = (messagePayload[@\" pn_other\" ]?: messagePayload);\n "
656+ " \t\t }\n "
657+ " \t\t NSLog(@\" Received message: %@ \" , messageData);\n "
658+ " \t }\n\n\n " ];
659+ NSLog (@" %@ " , deprecation);
660+ }
661+ }
662+
604663- (void )dealloc {
605664
606665#if TARGET_OS_IOS
0 commit comments