2017-07-14 87 views
0

我之前收到它在我的vritual设备中,但是在我从我的AVD卸载并重新安装我的应用之后,我没有收到任何消息,但在Firebase控制台中显示其完成状态。 .plz有人帮我我无法接收推送通知在我的vritual设备android

This is Main Activity 
 

 
import android.content.Intent; 
 
import android.support.v7.app.AppCompatActivity; 
 
import android.os.Bundle; 
 
import android.view.View; 
 
import android.widget.ImageButton; 
 

 
public class MainActivity extends AppCompatActivity { 
 

 
    @Override 
 
    protected void onCreate(Bundle savedInstanceState) { 
 
     super.onCreate(savedInstanceState); 
 
     setContentView(R.layout.activity_main); 
 
     ImageButton budbtn=(ImageButton)findViewById(R.id.buddies); 
 
     budbtn.setOnClickListener(new View.OnClickListener() { 
 
      @Override 
 
      public void onClick(View view) { 
 
       Intent intent= new Intent(MainActivity.this,BuddiesAct.class); 
 
       startActivity(intent); 
 
      } 
 
     }); 
 
     ImageButton prim=(ImageButton)findViewById(R.id.primary); 
 
     ImageButton senior=(ImageButton)findViewById(R.id.senior); 
 
     ImageButton suprsen=(ImageButton)findViewById(R.id.supersenior); 
 
    } 
 
}

Project level built gradle 
 

 
// Top-level build file where you can add configuration options common to all sub-projects/modules. 
 

 
buildscript { 
 
    repositories { 
 
     jcenter() 
 
    } 
 
    dependencies { 
 
     classpath 'com.android.tools.build:gradle:2.3.3' 
 
     classpath 'com.google.gms:google-services:3.1.0' 
 

 
     // NOTE: Do not place your application dependencies here; they belong 
 
     // in the individual module build.gradle files 
 
    } 
 
} 
 

 
allprojects { 
 
    repositories { 
 
     jcenter() 
 
    } 
 
} 
 

 
task clean(type: Delete) { 
 
    delete rootProject.buildDir 
 
}

apply plugin: 'com.android.application' 
 

 
android { 
 
    compileSdkVersion 26 
 
    buildToolsVersion "26.0.0" 
 
    defaultConfig { 
 
     applicationId "com.example.zion.kidskount" 
 
     minSdkVersion 16 
 
     targetSdkVersion 26 
 
     versionCode 1 
 
     versionName "1.0" 
 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
 
    } 
 
    buildTypes { 
 
     release { 
 
      minifyEnabled false 
 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
 
     } 
 
    } 
 
} 
 

 
dependencies { 
 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
 
     exclude group: 'com.android.support', module: 'support-annotations' 
 
    }) 
 
    apply plugin: 'com.google.gms.google-services' 
 
    compile 'com.android.support:appcompat-v7:26.+' 
 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
 
    compile 'gr.pantrif:easy-android-splash-screen:0.0.1' 
 
    compile 'com.google.firebase:firebase-messaging:9.0.0' 
 

 
    testCompile 'junit:junit:4.12' 
 
}

+0

您的AVD与Android O版本? –

+0

否4.2 @EmílioFonseca –

+0

您是否在重新安装应用程序后再次获得您的推送注册ID? –

回答

0

每当你重新安装或应用程序的明确数据,再次生成您的token

每次记录您的令牌onTokenRefresh()被称为here

因此,得到您的令牌并用它来发送您的推送通知:D

+0

非常感谢你的兄弟...非常感谢@Emilio Fonseca –