-
Notifications
You must be signed in to change notification settings - Fork 619
Migrate RC to depend directly on Installations SDK. #1579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
95cb9bd
fa509ae
a30b919
847cbac
62fbcb3
4e0fb24
baadaa8
34e356d
512df9d
01b4f73
0481a94
df620df
5dcf294
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,10 @@ | |
import androidx.annotation.IdRes; | ||
import androidx.fragment.app.Fragment; | ||
import com.google.android.gms.tasks.Task; | ||
import com.google.firebase.iid.FirebaseInstanceId; | ||
import com.google.android.gms.tasks.Tasks; | ||
import com.google.firebase.FirebaseApp; | ||
import com.google.firebase.installations.FirebaseInstallationsApi; | ||
import com.google.firebase.installations.InstallationTokenResult; | ||
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; | ||
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings; | ||
|
||
|
@@ -46,20 +49,25 @@ | |
public class ApiFragment extends Fragment { | ||
|
||
private FirebaseRemoteConfig frc; | ||
private FirebaseInstallationsApi firebaseInstallations; | ||
private View rootView; | ||
private EditText minimumFetchIntervalText; | ||
private EditText parameterKeyText; | ||
private TextView parameterValueText; | ||
private TextView apiCallProgressText; | ||
private TextView apiCallResultsText; | ||
|
||
private static final String TAG = "Bandwagoner"; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
frc = FirebaseRemoteConfig.getInstance(); | ||
frc.setConfigSettings( | ||
new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(true).build()); | ||
|
||
firebaseInstallations = FirebaseApp.getInstance().get(FirebaseInstallationsApi.class); | ||
} | ||
|
||
@Override | ||
|
@@ -87,9 +95,29 @@ public View onCreateView( | |
TextView sdkVersionText = rootView.findViewById(R.id.sdk_version_text); | ||
|
||
TextView iidText = rootView.findViewById(R.id.iid_text); | ||
iidText.setText("IID: " + FirebaseInstanceId.getInstance().getId()); | ||
|
||
apiCallResultsText.setText(FirebaseInstanceId.getInstance().getToken()); | ||
Task<String> installationIdTask = firebaseInstallations.getId(); | ||
Task<InstallationTokenResult> installationAuthTokenTask = firebaseInstallations.getToken(false); | ||
|
||
Tasks.whenAllComplete(installationIdTask, installationAuthTokenTask) | ||
.addOnCompleteListener( | ||
unusedCompletedTasks -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure there's a real convention in Android or Java, but we use "unused" consistently as a prefix in Remote Config at least, so I'd lean towards keeping it. |
||
if (installationIdTask.isSuccessful()) { | ||
iidText.setText( | ||
String.format("Installation ID: %s", installationIdTask.getResult())); | ||
} else { | ||
Log.e(TAG, "Error getting installation ID", installationIdTask.getException()); | ||
} | ||
|
||
if (installationAuthTokenTask.isSuccessful()) { | ||
apiCallResultsText.setText(installationAuthTokenTask.getResult().getToken()); | ||
} else { | ||
Log.e( | ||
TAG, | ||
"Error getting installation authentication token", | ||
installationAuthTokenTask.getException()); | ||
} | ||
}); | ||
|
||
return rootView; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.