Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiApp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RAHUL SHARMA
InstiApp
Commits
17066a1c
Commit
17066a1c
authored
Jul 30, 2018
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove use of deprecated API for getting FCM Id
parent
3d294b15
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
app/src/main/java/app/insti/LoginActivity.java
app/src/main/java/app/insti/LoginActivity.java
+15
-4
No files found.
app/src/main/java/app/insti/LoginActivity.java
View file @
17066a1c
...
...
@@ -14,7 +14,9 @@ import android.widget.Toast;
import
com.google.android.gms.common.ConnectionResult
;
import
com.google.android.gms.common.GoogleApiAvailability
;
import
com.google.android.gms.tasks.OnSuccessListener
;
import
com.google.firebase.iid.FirebaseInstanceId
;
import
com.google.firebase.iid.InstanceIdResult
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.ServiceGenerator
;
...
...
@@ -31,6 +33,7 @@ public class LoginActivity extends AppCompatActivity {
private
final
String
guestUri
=
"https://guesturi"
;
private
boolean
loggingIn
=
false
;
public
String
authCode
=
null
;
public
String
fcmId
=
null
;
SessionManager
session
;
Context
mContext
=
this
;
private
ProgressDialog
progressDialog
;
...
...
@@ -63,16 +66,24 @@ public class LoginActivity extends AppCompatActivity {
webview
.
getSettings
().
setDomStorageEnabled
(
true
);
webview
.
setWebViewClient
(
new
WvClient
());
webview
.
loadUrl
(
"file:///android_asset/login.html"
);
// Get FCM Id
FirebaseInstanceId
.
getInstance
().
getInstanceId
().
addOnSuccessListener
(
new
OnSuccessListener
<
InstanceIdResult
>()
{
@Override
public
void
onSuccess
(
InstanceIdResult
instanceIdResult
)
{
fcmId
=
instanceIdResult
.
getToken
();
}
});
}
private
void
login
(
final
String
authorizationCode
,
final
String
redirectURL
)
{
/* This can be null if play services is hung */
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
Call
<
LoginResponse
>
call
;
if
(
FirebaseInstanceId
.
getInstance
().
getToken
()
==
null
)
{
if
(
fcmId
==
null
)
{
call
=
retrofitInterface
.
login
(
authorizationCode
,
redirectURL
);
}
else
{
call
=
retrofitInterface
.
login
(
authorizationCode
,
redirectURL
,
FirebaseInstanceId
.
getInstance
().
getToken
()
);
call
=
retrofitInterface
.
login
(
authorizationCode
,
redirectURL
,
fcmId
);
}
call
.
enqueue
(
new
Callback
<
LoginResponse
>()
{
...
...
@@ -109,10 +120,10 @@ public class LoginActivity extends AppCompatActivity {
Call
<
LoginResponse
>
call
;
/* This can be null if play services is hung */
if
(
FirebaseInstanceId
.
getInstance
().
getToken
()
==
null
)
{
if
(
fcmId
==
null
)
{
call
=
retrofitInterface
.
passwordLogin
(
username
,
password
);
}
else
{
call
=
retrofitInterface
.
passwordLogin
(
username
,
password
,
FirebaseInstanceId
.
getInstance
().
getToken
()
);
call
=
retrofitInterface
.
passwordLogin
(
username
,
password
,
fcmId
);
}
/* Log in the user */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment