Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Top-level build file where you can add configuration options common to all sub-projects/modules.
- buildscript {
- repositories {
- google()
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:3.3.0'
- classpath 'com.google.gms:google-services:4.2.0'
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- }
- }
- allprojects {
- repositories {
- google()
- jcenter()
- }
- }
- task clean(type: Delete) {
- delete rootProject.buildDir
- }
- apply plugin: 'com.android.application'
- apply plugin: 'com.google.gms.google-services'
- com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
- android {
- compileSdkVersion 28
- buildToolsVersion "28.0.3"
- defaultConfig {
- applicationId "com.***"
- minSdkVersion 19
- targetSdkVersion 28
- versionCode 1
- versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- vectorDrawables.useSupportLibrary = true
- multiDexEnabled = true
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- }
- dependencies {
- implementation fileTree(include: ['*.jar'], dir: 'libs')
- //noinspection GradleCompatible
- implementation 'com.android.support:appcompat-v7:28.0.0'
- implementation 'com.android.support:recyclerview-v7:28.0.0'
- implementation 'com.android.support:design:28.0.0'
- implementation 'com.android.support.constraint:constraint-layout:1.1.3'
- ...
- implementation('com.google.android.gms:play-services-base:16.0.1') {
- exclude module: 'support-v4'
- }
- implementation('com.google.android.gms:play-services-maps:16.0.0') {
- exclude module: 'support-v4'
- }
- implementation('com.google.android.gms:play-services-places:16.0.0') {
- exclude module: 'support-v4'
- }
- implementation 'com.google.firebase:firebase-core:16.0.6'
- implementation 'com.google.firebase:firebase-iid:17.0.4'
- implementation 'com.google.firebase:firebase-messaging:17.3.4'
- }
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.**">
- <uses-permission android:name="android.permission.INTERNET"/>
- <application
- android:name=".ApplicationClass"
- android:allowBackup="true"
- android:icon="@drawable/app_icon"
- android:label="@string/app_name"
- android:roundIcon="@drawable/app_icon"
- android:supportsRtl="true"
- android:theme="@style/AppTheme">
- <activity
- android:name=".MainActivity"
- android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
- <meta-data
- android:name="com.google.android.geo.API_KEY"
- android:value="***"/>
- <activity
- android:name=".LoginActivity"
- android:theme="@style/Theme.AppCompat.Light.NoActionBar">
- <intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER"/>
- </intent-filter>
- </activity>
- <service
- android:name=".MyFirebaseInstanceIDService"
- android:enabled="true"
- android:exported="true">
- <intent-filter>
- <action android:name="com.google.firebase.MESSAGING_EVENT"/>
- </intent-filter>
- </service>
- <meta-data
- android:name="com.google.firebase.messaging.default_notification_icon"
- android:resource="@drawable/logo" />
- </application>
- </manifest>
- FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() {
- @Override
- public void onSuccess(InstanceIdResult instanceIdResult) {
- refreshedToken = instanceIdResult.getToken();
- Log.e("refreshedToken", refreshedToken);
- // Do whatever you want with your token now
- // i.e. store it on SharedPreferences or DB
- // or directly send it to server
- }
- });
Add Comment
Please, Sign In to add comment