@@ -557,6 +557,42 @@ private CallableOperation<TopicManagementResponse, FirebaseMessagingException> s
557557 final List <String > registrationTokens , final String topic ) {
558558 checkRegistrationTokens (registrationTokens );
559559 checkTopic (topic );
560+ final FirebaseMessagingClient messagingClient = getMessagingClient ();
561+ return new CallableOperation <TopicManagementResponse , FirebaseMessagingException >() {
562+ @ Override
563+ protected TopicManagementResponse execute () throws FirebaseMessagingException {
564+ return messagingClient .subscribeToTopic (topic , registrationTokens );
565+ }
566+ };
567+ }
568+
569+ /**
570+ * Subscribes a list of registration tokens to a topic using the legacy Instance ID API.
571+ *
572+ * @deprecated Use {@link #subscribeToTopic(List, String)} instead.
573+ */
574+ @ Deprecated
575+ public TopicManagementResponse subscribeToTopicLegacy (@ NonNull List <String > registrationTokens ,
576+ @ NonNull String topic ) throws FirebaseMessagingException {
577+ return subscribeLegacyOp (registrationTokens , topic ).call ();
578+ }
579+
580+ /**
581+ * Similar to {@link #subscribeToTopicLegacy(List, String)} but performs the operation
582+ * asynchronously.
583+ *
584+ * @deprecated Use {@link #subscribeToTopicAsync(List, String)} instead.
585+ */
586+ @ Deprecated
587+ public ApiFuture <TopicManagementResponse > subscribeToTopicLegacyAsync (
588+ @ NonNull List <String > registrationTokens , @ NonNull String topic ) {
589+ return subscribeLegacyOp (registrationTokens , topic ).callAsync (app );
590+ }
591+
592+ private CallableOperation <TopicManagementResponse , FirebaseMessagingException > subscribeLegacyOp (
593+ final List <String > registrationTokens , final String topic ) {
594+ checkRegistrationTokens (registrationTokens );
595+ checkTopic (topic );
560596 final InstanceIdClient instanceIdClient = getInstanceIdClient ();
561597 return new CallableOperation <TopicManagementResponse , FirebaseMessagingException >() {
562598 @ Override
@@ -597,6 +633,43 @@ private CallableOperation<TopicManagementResponse, FirebaseMessagingException> u
597633 final List <String > registrationTokens , final String topic ) {
598634 checkRegistrationTokens (registrationTokens );
599635 checkTopic (topic );
636+ final FirebaseMessagingClient messagingClient = getMessagingClient ();
637+ return new CallableOperation <TopicManagementResponse , FirebaseMessagingException >() {
638+ @ Override
639+ protected TopicManagementResponse execute () throws FirebaseMessagingException {
640+ return messagingClient .unsubscribeFromTopic (topic , registrationTokens );
641+ }
642+ };
643+ }
644+
645+ /**
646+ * Unsubscribes a list of registration tokens from a topic using the legacy Instance ID API.
647+ *
648+ * @deprecated Use {@link #unsubscribeFromTopic(List, String)} instead.
649+ */
650+ @ Deprecated
651+ public TopicManagementResponse unsubscribeFromTopicLegacy (
652+ @ NonNull List <String > registrationTokens ,
653+ @ NonNull String topic ) throws FirebaseMessagingException {
654+ return unsubscribeLegacyOp (registrationTokens , topic ).call ();
655+ }
656+
657+ /**
658+ * Similar to {@link #unsubscribeFromTopicLegacy(List, String)} but performs the operation
659+ * asynchronously.
660+ *
661+ * @deprecated Use {@link #unsubscribeFromTopicAsync(List, String)} instead.
662+ */
663+ @ Deprecated
664+ public ApiFuture <TopicManagementResponse > unsubscribeFromTopicLegacyAsync (
665+ @ NonNull List <String > registrationTokens , @ NonNull String topic ) {
666+ return unsubscribeLegacyOp (registrationTokens , topic ).callAsync (app );
667+ }
668+
669+ private CallableOperation <TopicManagementResponse , FirebaseMessagingException >
670+ unsubscribeLegacyOp (final List <String > registrationTokens , final String topic ) {
671+ checkRegistrationTokens (registrationTokens );
672+ checkTopic (topic );
600673 final InstanceIdClient instanceIdClient = getInstanceIdClient ();
601674 return new CallableOperation <TopicManagementResponse , FirebaseMessagingException >() {
602675 @ Override
0 commit comments