Skip to content

Commit 128e1b0

Browse files
Retain OAuthProvider instance in sample app (#2577)
1 parent 966ad68 commit 128e1b0

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Example/Auth/Sample/MainViewController.m

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,16 @@ @implementation MainViewController {
732732
@brief The continue URL to be used in the next action code request.
733733
*/
734734
NSURL *_actionCodeContinueURL;
735+
736+
/** @var _googleOAuthProvider
737+
@brief OAuth provider instance for Google.
738+
*/
739+
FIROAuthProvider *_googleOAuthProvider;
740+
741+
/** @var _microsoftOAuthProvider
742+
@brief OAuth provider instance for Microsoft.
743+
*/
744+
FIROAuthProvider *_microsoftOAuthProvider;
735745
}
736746

737747
/** @fn initWithNibName:bundle:
@@ -744,6 +754,8 @@ - (id)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundl
744754
_actionCodeContinueURL = [NSURL URLWithString:KCONTINUE_URL];
745755
_authStateDidChangeListeners = [NSMutableArray array];
746756
_IDTokenDidChangeListeners = [NSMutableArray array];
757+
_googleOAuthProvider = [FIROAuthProvider providerWithProviderID:FIRGoogleAuthProviderID];
758+
_microsoftOAuthProvider = [FIROAuthProvider providerWithProviderID:@"microsoft.com"];
747759
[[NSNotificationCenter defaultCenter] addObserver:self
748760
selector:@selector(authStateChangedForAuth:)
749761
name:FIRAuthStateDidChangeNotification
@@ -1782,7 +1794,7 @@ - (void)signInGoogleAndRetrieveData {
17821794
}
17831795

17841796
- (void)signInGoogleProvider {
1785-
FIROAuthProvider *provider = [FIROAuthProvider providerWithProviderID:FIRGoogleAuthProviderID];
1797+
FIROAuthProvider *provider = _googleOAuthProvider;
17861798
provider.customParameters = @{
17871799
@"prompt" : @"consent",
17881800
};
@@ -1816,7 +1828,7 @@ - (void)signInGoogleProvider {
18161828
@brief Invoked when "Sign in with Google (headful-lite)" row is pressed.
18171829
*/
18181830
- (void)signInGoogleHeadfulLite {
1819-
FIROAuthProvider *provider = [FIROAuthProvider providerWithProviderID:FIRGoogleAuthProviderID];
1831+
FIROAuthProvider *provider = _googleOAuthProvider;
18201832
provider.customParameters = @{
18211833
@"prompt" : @"consent",
18221834
};
@@ -1850,7 +1862,7 @@ - (void)signInGoogleHeadfulLite {
18501862
@brief Invoked when "Sign in with Microsoft (headful-lite)" row is pressed.
18511863
*/
18521864
- (void)signInMicrosoftHeadfulLite {
1853-
FIROAuthProvider *provider = [FIROAuthProvider providerWithProviderID:@"microsoft.com"];
1865+
FIROAuthProvider *provider = _microsoftOAuthProvider;
18541866
provider.customParameters = @{
18551867
@"prompt" : @"consent",
18561868
@"login_hint" : @"[email protected]",

0 commit comments

Comments
 (0)