File tree Expand file tree Collapse file tree 10 files changed +42
-81
lines changed
androidTest/java/com/trenzlr/firebasesample
java/com/trenzlr/firebasesample
test/java/com/trenzlr/firebasesample
firebasenotificationhelper/src/main/java/com/trenzlr/firebasenotificationhelper Expand file tree Collapse file tree 10 files changed +42
-81
lines changed Original file line number Diff line number Diff line change 1
1
apply plugin : ' com.android.application'
2
2
3
3
android {
4
- compileSdkVersion 26
4
+ compileSdkVersion 29
5
5
defaultConfig {
6
6
applicationId " com.trenzlr.firebasesample"
7
7
minSdkVersion 16
8
- targetSdkVersion 26
8
+ targetSdkVersion 29
9
9
versionCode 1
10
10
versionName " 1.0"
11
- testInstrumentationRunner " android.support .test.runner.AndroidJUnitRunner"
11
+ testInstrumentationRunner " androidx .test.runner.AndroidJUnitRunner"
12
12
}
13
13
buildTypes {
14
14
release {
@@ -20,12 +20,9 @@ android {
20
20
21
21
dependencies {
22
22
implementation fileTree(include : [' *.jar' ], dir : ' libs' )
23
- implementation ' com.android.support:appcompat-v7:26.1.0'
24
- implementation ' com.android.support.constraint:constraint-layout:1.0.2'
25
- implementation ' com.google.firebase:firebase-messaging:11.0.4'
26
- testImplementation ' junit:junit:4.12'
27
- androidTestImplementation ' com.android.support.test:runner:1.0.1'
28
- androidTestImplementation ' com.android.support.test.espresso:espresso-core:3.0.1'
23
+ implementation ' androidx.appcompat:appcompat:1.0.2'
24
+ implementation ' androidx.constraintlayout:constraintlayout:1.1.3'
25
+ implementation ' com.google.firebase:firebase-messaging:20.0.0'
29
26
implementation project(' :firebasenotificationhelper' )
30
27
}
31
28
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
package com .trenzlr .firebasesample ;
2
2
3
- import com .google .firebase .iid .FirebaseInstanceId ;
4
- import com .google .firebase .iid .FirebaseInstanceIdService ;
5
3
6
4
7
5
/**
8
6
* Created by prabh on 25-10-2017.
9
7
*/
10
8
11
- public class FirebaseIDService extends FirebaseInstanceIdService {
12
- private static final String TAG = "FirebaseIDService" ;
13
- public static final String FIREBASE_TOKEN = "token" ;
14
-
15
-
16
- @ Override
17
- public void onTokenRefresh () {
18
- // Get updated InstanceID token.
19
- String refreshedToken = FirebaseInstanceId .getInstance ().getToken ();
20
- SharedPrefUtil .getInstance (this ).put (FIREBASE_TOKEN ,refreshedToken );
21
-
22
- }
23
-
24
-
25
- }
9
+ // public class FirebaseIDService extends FirebaseInstanceId {
10
+ // private static final String TAG = "FirebaseIDService";
11
+ // public static final String FIREBASE_TOKEN = "token";
12
+ //
13
+ //
14
+ // @Override
15
+ // public void onTokenRefresh() {
16
+ // // Get updated InstanceID token.
17
+ // String refreshedToken = FirebaseInstanceId.getInstance().getToken();
18
+ // SharedPrefUtil.getInstance(this).put(FIREBASE_TOKEN,refreshedToken);
19
+ //
20
+ // }
21
+ //
22
+ //
23
+ // }
Original file line number Diff line number Diff line change 1
1
package com .trenzlr .firebasesample ;
2
2
3
3
import android .os .Bundle ;
4
- import android .support .v7 .app .AppCompatActivity ;
5
4
import android .util .Log ;
6
5
import android .view .View ;
7
6
import android .widget .Button ;
8
7
import android .widget .Toast ;
9
8
9
+ import androidx .appcompat .app .AppCompatActivity ;
10
+
10
11
import com .trenzlr .firebasenotificationhelper .FirebaseNotiCallBack ;
11
12
import com .trenzlr .firebasenotificationhelper .FirebaseNotificationHelper ;
12
13
15
16
16
17
import static com .trenzlr .firebasesample .Constants .KEY_TEXT ;
17
18
import static com .trenzlr .firebasesample .Constants .KEY_TITLE ;
18
- import static com .trenzlr .firebasesample .FirebaseIDService .FIREBASE_TOKEN ;
19
+ import static com .trenzlr .firebasesample .MyFirebaseMessagingService .FIREBASE_TOKEN ;
20
+
19
21
20
22
public class MainActivity extends AppCompatActivity implements FirebaseNotiCallBack {
21
23
private Button sendMess , sendMess2 ;
Original file line number Diff line number Diff line change 10
10
import android .media .RingtoneManager ;
11
11
import android .net .Uri ;
12
12
import android .os .Build ;
13
- import android .os .Bundle ;
14
- import android .support .v4 .app .NotificationCompat ;
13
+
14
+ import androidx .annotation .NonNull ;
15
+ import androidx .core .app .NotificationCompat ;
15
16
16
17
import com .google .firebase .messaging .FirebaseMessagingService ;
17
18
import com .google .firebase .messaging .RemoteMessage ;
18
19
20
+
19
21
/**
20
22
* Created by prabh on 25-10-2017.
21
23
*/
@@ -24,6 +26,13 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService {
24
26
private static final String TAG = "FCM Service" ;
25
27
private Bitmap bitmap ;
26
28
private Context context = this ;
29
+ public static final String FIREBASE_TOKEN = "token" ;
30
+
31
+ @ Override
32
+ public void onNewToken (@ NonNull String refreshedToken ) {
33
+ super .onNewToken (refreshedToken );
34
+ SharedPrefUtil .getInstance (this ).put (FIREBASE_TOKEN , refreshedToken );
35
+ }
27
36
28
37
@ Override
29
38
public void onMessageReceived (RemoteMessage remoteMessage ) {
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
- <android .support.constraint .ConstraintLayout xmlns : android =" http://schemas.android.com/apk/res/android"
2
+ <androidx .constraintlayout.widget .ConstraintLayout xmlns : android =" http://schemas.android.com/apk/res/android"
3
3
xmlns : app =" http://schemas.android.com/apk/res-auto"
4
4
xmlns : tools =" http://schemas.android.com/tools"
5
5
android : layout_width =" match_parent"
29
29
app : layout_constraintTop_toTopOf =" parent"
30
30
app : layout_constraintVertical_bias =" 0.676" />
31
31
32
- </android .support.constraint .ConstraintLayout>
32
+ </androidx .constraintlayout.widget .ConstraintLayout>
Original file line number Diff line number Diff line change 1
1
<resources >
2
2
<string name =" app_name" >FirebaseSample</string >
3
- <string name =" token" >db2tlCennF8:APA91bE1YGlIM8-f8UizSumJlJORlI4nITZ_p2g8mtRMXHmy9dYYLcDjzs3EUbglMQ25ritk62C4glDJOhFfqtAeUhBUfWSgWCPXbI0D0xK0vsKXzM_ZvVK1aOa24UFY65Xrh4fNcbH </string >
4
- <string name =" server_key" >AAAAVRCSZOg:APA91bEhTBNmNFld6cVnn8lHvR2XVO0TQoRtcD8Q_iUelNG9zLH6_p6gPLPd64cpy0issHd_9qo6rzedFleinlTPWu9gPt_NTw-sbo7qGDt41XESLutNXT-8cDnrvy2Ib5emm629atLVeDmhQe8JbmE6IJ1I65Q2vQ </string >
3
+ <string name =" token" >ss </string >
4
+ <string name =" server_key" >sss </string >
5
5
</resources >
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
2
<full-backup-content >
3
- <!-- TODO Remove the following "exclude" elements to make them a part of the auto backup -->
4
3
<!-- Exclude the shared preferences file that contains the GCM registrationId -->
5
4
<exclude
6
5
domain =" sharedpref"
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 15
15
import java .io .Writer ;
16
16
import java .net .HttpURLConnection ;
17
17
import java .net .URL ;
18
+ import java .nio .charset .StandardCharsets ;
18
19
19
20
import static android .content .ContentValues .TAG ;
20
21
import static com .trenzlr .firebasenotificationhelper .Constants .APPLICATION_JSON ;
@@ -50,7 +51,7 @@ protected String doInBackground(String... strings) {
50
51
urlConnection .setRequestProperty (CONTENT_TYPE , APPLICATION_JSON );
51
52
urlConnection .setRequestProperty (AUTHORIZATION , authKey );
52
53
//set headers and method
53
- Writer writer = new BufferedWriter (new OutputStreamWriter (urlConnection .getOutputStream (), "UTF-8" ));
54
+ Writer writer = new BufferedWriter (new OutputStreamWriter (urlConnection .getOutputStream (), StandardCharsets . UTF_8 ));
54
55
writer .write (JsonDATA );
55
56
// json data
56
57
writer .close ();
@@ -90,9 +91,7 @@ protected String doInBackground(String... strings) {
90
91
}
91
92
}
92
93
}
93
-
94
94
return JsonResponse ;
95
-
96
95
}
97
96
98
97
@ Override
You can’t perform that action at this time.
0 commit comments