For Firebase installation ID (FID) or migrate from Instance ID to FID, please consult here.
do {
let id = try await Installations.installations().installationID()
print("Installation ID: \(id)")
} catch {
print("Error fetching id: \(error)")
}[[FIRInstallations installations] installationIDWithCompletion:^(NSString *identifier, NSError *error) {
if (error != nil) {
NSLog(@"Error fetching Installation ID %@", error);
return;
}
NSLog(@"Installation ID: %@", identifier);
}];
FirebaseInstallations.getInstance().getId()
.addOnCompleteListener(new OnCompleteListener<String>() {
@Override
public void onComplete(@NonNull Task<String> task) {
if (task.isSuccessful()) {
Log.d("Installations", "Installation ID: " + task.getResult());
} else {
Log.e("Installations", "Unable to get Installation ID");
}
}
});FirebaseInstallations.getInstance().id.addOnCompleteListener { task ->
if (task.isSuccessful) {
Log.d("Installations", "Installation ID: " + task.result)
} else {
Log.e("Installations", "Unable to get Installation ID")
}
}const installationId = await firebase.installations().getId();
console.log(installationId);String id = await FirebaseInstallations.instance.getId();Firebase Docs
- Android: public Task getAppInstanceId ()
- iOS: appInstanceID()
Example for Android
FirebaseAnalytics.getInstance(this).getAppInstanceId().addOnCompleteListener(new OnCompleteListener<String>() {
@Override
public void onComplete(@NonNull Task<String> task) {
if (task.isSuccessful()) {
String user_pseudo_id = task.getResult();
}
}
});JavaScript
var gaUserId = document.cookie.match(/_ga=(.+?);/)[1].split('.').slice(-2).join(".")PHP
$gaUserId = preg_replace("/^.+\.(.+?\..+?)$/", "\\1", @$_COOKIE['_ga']);