I’m trying to set up an application to work with gcm but every time I get the phone_registration_error error
according to the Gcm documentation this error means:
Incorrect phone registration with Google.
This phone doesn't currently support GCM.
But I don’t understand why my it’s not supported, I tested this on a real android device and a emulator with the google api’s
My MainActivity:
@Override
public void onCreate(Bundle savedInstanceState) {
checkNotNull(SENDER_ID, "SENDER_ID");
GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
final String regId = GCMRegistrar.getRegistrationId(this);
Log.i(TAG, "registration id ===== "+regId);
if(regId.equals("")){
GCMRegistrar.register(this, SENDER_ID);
} else {
Log.v(TAG, "Already Registred");
}
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
And my manifest:
GCM only works on devices that run android 2.2 or newer. Also GCM only works if a google account is installed for the device. This is also the reason google recommend using
<uses-permission android:name="android.permission.GET_ACCOUNTS" />in the manifest so you are sure the device has a google account.