1

我正在使用 GCM 使用推送通知,但没有从 GCM 收到 RegID。在某些设备中它很少给我 id?

这是我的代码

// Make sure the device has the proper dependencies.                                               
GCMRegistrar.checkDevice(this);                                                                    
GCMRegistrar.checkManifest(this);                                                                  

registerReceiver(mHandleMessageReceiver, new IntentFilter(CommonUtilities.DISPLAY_MESSAGE_ACTION));



String str= GCMRegistrar.getRegistrationId(SelectLogin.this);                                      

Const.GCM_RegId =str;                                                                              
Log.print(" ------------First  regId :::::"+Const.GCM_RegId);                                      

// Check if regid already presents                                                                 
if (Const.GCM_RegId.equals(""))                                                                    
{                                                                                                  
    // Registration is not present, register now with GCM                                          
    GCMRegistrar.register(this, CommonUtilities.SENDER_ID);                                        
}                                                                                                  
else {                                                                                             
    // Device is already registered on GCM                                                         
    if (GCMRegistrar.isRegisteredOnServer(this)) {                                                 

    }                                                                                              
    else                                                                                           
    {                                                                                              
        if(WebInterface.isOnline(SelectLogin.this))                                                
        {                                                                                          
            new RegisterGCM(SelectLogin.this, Const.GCM_RegId).execute();                          
        }                                                                                          

    }                                                                                              
}                                                                                                  

这是清单 在此处输入图像描述

4

0 回答 0