Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static com.google.firebase.firestore.AggregateField.count;
import static com.google.firebase.firestore.AggregateField.sum;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.util.Log;
import androidx.annotation.NonNull;
Expand All @@ -33,6 +34,7 @@
import com.google.firebase.firestore.Source;
import com.google.firebase.firestore.Transaction;
import com.google.firebase.firestore.WriteBatch;
import com.google.firebase.firestore.remote.FirestoreChannel;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
Expand Down Expand Up @@ -129,9 +131,12 @@ private static void destroyCachedFirebaseFirestoreInstanceForKey(FirebaseFiresto
}
}

@SuppressLint("RestrictedApi")
@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
initInstance(binding.getBinaryMessenger());
FirestoreChannel.setClientLanguage(
"gl-dart/" + io.flutter.plugins.firebase.firestore.BuildConfig.LIBRARY_VERSION);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Pod::Spec.new do |s|
s.license = { :file => '../LICENSE' }
s.authors = 'The Chromium Authors'
s.source = { :path => '.' }
s.source_files = 'cloud_firestore/Sources/cloud_firestore/**/*.{h,m}'
s.source_files = 'cloud_firestore/Sources/cloud_firestore/**/*.{h,m,mm}'
s.public_header_files = 'cloud_firestore/Sources/cloud_firestore/include/Public/**/*.h'
s.private_header_files = 'cloud_firestore/Sources/cloud_firestore/include/Private/**/*.h'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
NSString *const kFLTFirebaseFirestoreLoadBundleChannelName =
@"plugins.flutter.io/firebase_firestore/loadBundle";

@interface FLTFirestoreClientLanguage : NSObject
+ (void)setClientLanguage:(NSString *)language;
@end

@interface FLTFirebaseFirestorePlugin ()
@property(nonatomic, retain) NSMutableDictionary *transactions;

Expand Down Expand Up @@ -122,6 +126,10 @@ - (instancetype)init:(NSObject<FlutterBinaryMessenger> *)messenger {
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
FLTFirebaseFirestorePlugin *instance =
[[FLTFirebaseFirestorePlugin alloc] init:[registrar messenger]];
#if TARGET_OS_IPHONE
[FLTFirestoreClientLanguage
setClientLanguage:[NSString stringWithFormat:@"gl-dart/%@", @LIBRARY_VERSION]];
#endif

#if TARGET_OS_OSX
// TODO(Salakar): Publish does not exist on MacOS version of FlutterPluginRegistrar.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2025 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Foundation/Foundation.h>
#import <string>

namespace firebase {
namespace firestore {
namespace api {

class Firestore {
public:
static void SetClientLanguage(std::string language_token);
};

} // namespace api
} // namespace firestore
} // namespace firebase

@interface FLTFirestoreClientLanguage : NSObject
+ (void)setClientLanguage:(NSString *)language;
@end

@implementation FLTFirestoreClientLanguage
+ (void)setClientLanguage:(NSString *)language {
if (language == nil) {
return;
}
std::string token = std::string([language UTF8String]);
firebase::firestore::api::Firestore::SetClientLanguage(token);
}
@end
Loading