I am trying to use gcm to push notifications on android devices. So far I have registered with gcm and sent my back-end the necessary information to make a post request to the gcm severs which builds a 200 response. All the steps have come together except the client side receiving the message. I don't get the message. Displayed here is my gcm listener class:
import com.google.android.gms.gcm.GcmListenerService;
public class MyGcmListenerService extends GcmListenerService {
public static final int MESSAGE_NOTIFICATION_ID = 435345;
private static final String TAG = "MyGcmListenerService";
#Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
Log.d(TAG, "From: " + from);
Log.d(TAG, "Message: " + message);
sendNotification(from,message);
}
private void sendNotification(String title, String body) {
Context context = getBaseContext();
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher).setContentTitle(title)
.setContentText(body);
NotificationManager mNotificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(MESSAGE_NOTIFICATION_ID, mBuilder.build());
}
}
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.google.android.c2dm.permission.RECEIVE"/>
<permission android:name="com.example.caesar.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.caesar.gcm.permission.C2D_MESSAGE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<recieve android:name = ".GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.example.caesar.gcm" />
</intent-filter>
</recieve>
</application>
// new manifest file
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.google.android.c2dm.permission.RECEIVE"/>
<permission android:name="com.example.caesar.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.caesar.gcm.permission.C2D_MESSAGE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<reciever
android:name = "com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.example.caesar.gcm" />
</intent-filter>
</reciever>
<service
android:name="com.example.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.example.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
</application>
Actually looking at this further it looks like you haven't setup the receiver correctly. Seems you need to include at least.
<service
android:name="com.example.MyGcmListenerService "
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
And for the rest just follow that link.
You have to put your resgistration intent service at the end of yout Manifest file. Like this example:
<service
android:name="com.example.gcm.RegistrationIntentService"
android:exported="false">
</service>
Hope that help you, more information, you can visit this link and you can view an example of RegistrationIntentService here.
Related
So I want to point the app to start a particular activity instead of the LaunchActivity that was set up. I changed the Manifest to start up with the activity of choice, but it keeps throwing this error
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.parabit.parabeacon.app.demo, PID: 23417
io.reactivex.exceptions.OnErrorNotImplementedException: The exception was not handled due to missing onError handler in the subscribe() method call. Further reading: https://github.com/ReactiveX/RxJava/wiki/Error-Handling | com.parabit.parabeacon.app.demo.exceptions.local_storage_exception.EmptyUserSessionStorageException: local storage is empty
at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
at io.reactivex.internal.observers.ConsumerSingleObserver.onError(ConsumerSingleObserver.java:46)
at io.reactivex.internal.operators.single.SingleObserveOn$ObserveOnSingleObserver.run(SingleObserveOn.java:79)
at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: com.parabit.parabeacon.app.demo.exceptions.local_storage_exception.EmptyUserSessionStorageException: local storage is empty
at com.parabit.parabeacon.app.demo.data_section.LocalStorage.lambda$getUserSessionInfo$18(LocalStorage.java:266)
at com.parabit.parabeacon.app.demo.data_section.LocalStorage$$ExternalSyntheticLambda6.subscribe(Unknown Source:2)
at io.reactivex.internal.operators.single.SingleCreate.subscribeActual(SingleCreate.java:39)
at io.reactivex.Single.subscribe(Single.java:3666)
at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:608)
at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
The method in question is this:
#Throws(exceptionClasses = EmptyUserSessionStorageException.class)
public static Single<UserSession> getUserSessionInfo(#NonNull Context context) {
return Single.create(emitter -> {
String json = FileUtil.readContentFromFile(USER_SESSION_FILE_NAME, context);
if (json == null) {
emitter.onError(new EmptyUserSessionStorageException());
} else {
emitter.onSuccess(GsonUtil.jsonStrToObject(json, new TypeToken<UserSession>(){}));
}
});
}
And here's the Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.parabit.parabeacon.app.demo">
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name="com.parabit.parabeacon.app.demo.DemoApplication"
android:requestLegacyExternalStorage="true"
android:allowBackup="true"
android:icon="${iconpath}"
android:label="#string/app_name"
android:roundIcon="#mipmap/shape"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="com.parabit.parabeacon.app.demo.ui_section.HomeActivity"
android:label="#string/title_activity_home"
android:windowSoftInputMode="adjustPan"
android:exported="true">
<meta-data
android:name="android.app.default_searchable"
android:value=".bank_location.SearchableActivity" />
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.parabit.parabeacon.app.demo.ui_section.BtNotificationActivity"
android:label="#string/title_activity_bt_notification"
android:theme="#style/AppTheme.NoActionBar" />
<receiver
android:name="com.parabit.parabeacon.app.demo.receivers.BTServiceReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.parabit.parabeacon.app.sdk_app.receivers.bt_service_action" />
</intent-filter>
</receiver>
<activity
android:name="com.parabit.parabeacon.app.demo.ui_section.LoginActivity"
android:windowSoftInputMode="adjustResize"
android:noHistory="true"/>
<!-- <activity-->
<!-- android:name="com.parabit.parabeacon.app.demo.ui_section.HomeActivity"-->
<!-- android:label="#string/title_activity_home"-->
<!-- android:windowSoftInputMode="adjustPan">-->
<!-- <meta-data-->
<!-- android:name="android.app.default_searchable"-->
<!-- android:value=".bank_location.SearchableActivity" />-->
<!-- </activity>-->
<activity
android:name="com.parabit.parabeacon.app.demo.ui_section.SettingsActivity"
android:label="#string/title_app_settings" />
<activity android:name="com.parabit.parabeacon.app.demo.ui_section.bank_location.BankLocationDetailActivity" />
<activity
android:name="com.parabit.parabeacon.app.demo.ui_section.InviteActivity"
android:windowSoftInputMode="adjustPan"
android:label="#string/title_app_invite" />
<activity
android:name="com.parabit.parabeacon.app.demo.ui_section.InvitedUserActivity"
android:windowSoftInputMode="adjustPan"
android:label="#string/title_app_invited_user" />
<activity
android:name="com.parabit.parabeacon.app.demo.ui_section.bank_location.SearchableActivity"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustPan"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
</activity>
<service
android:name="org.altbeacon.beacon.service.BeaconService"
tools:node="replace">
<meta-data
android:name="longScanForcingEnabled"
android:value="true" />
</service>
<receiver android:name="org.altbeacon.beacon.startup.StartupBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</receiver>
<activity
android:name="com.microsoft.appcenter.distribute.DeepLinkActivity"
android:theme="#android:style/Theme.NoDisplay"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="updates"
android:path="/"
android:scheme="appcenter" />
</intent-filter>
</activity>
<receiver android:name="com.microsoft.appcenter.distribute.DownloadManagerReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
<action android:name="android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED" />
</intent-filter>
</receiver>
</application>
</manifest>
For a bit more context. The project is using RxJava to handle the Login process in the app (which is causing another issue in of itself). So I wanted to check the Home Activity and see if the app is still good to go. But I just can't get passed this error. Any ideas or help will be greatly appreciated. Thank you
P.S. I did not code this app. And Java isn't my main coding language I use to code Android, so I'm a bit shaky with it.
I'm trying to put an app on google and they reject it in addition to not giving me a concrete answer.
It's an SMS-sending app. I don't keep any user data.
The user fills in 3 fields and is sent to a predefined toll-free number, which sends a reply.
The part of the number and the answer is not up to the app: it is just to facilitate the user's work.
Here is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.SEND_SMS"/>
<application
android:allowBackup="true"
android:dataExtractionRules="#xml/data_extraction_rules"
android:fullBackupContent="#xml/backup_rules"
android:icon="#drawable/tres"
android:label="#string/app_name"
android:roundIcon="#drawable/tres"
android:supportsRtl="true"
android:theme="#style/Theme.FieldLocalize"
tools:targetApi="31">
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-4545343114224253~3369918696"/>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
</application>
</manifest>
private void requerirPermissao() {
if (!permissaoConcedida()) {
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.SEND_SMS}, 1);
}
}
private boolean permissaoConcedida() {
return ContextCompat.checkSelfPermission(this, android.Manifest.permission.SEND_SMS)
== PackageManager.PERMISSION_GRANTED;
}
I created a basic app to check whether broadcast is received when phone state is changed, but it is not working. I tried with making outgoing call and incoming calls too. I realized these are common issues with Vivo, Honor etc. Here is Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jss.servicetester">
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".ReceiverMe">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
</application>
</manifest>
And here is code for receiver:
package jss.servicetester;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
/**
* Created by DELL WORLD on 5/28/2017.
*/
public class ReceiverMe extends BroadcastReceiver {
String LOGTAG = "Receiver";
#Override
public void onReceive(Context context, Intent intent) {
Log.d(LOGTAG, "action:" + intent.getAction());
}
}
Can anyone help me.
started working in oppo F3 after making some changes in battery options for application. Like Unfreeze app in background.
Current Behavior:
The messages are being broadcast, but the receiver never gets them. I know this because the print statement in the broadcaster is printed, but the print statement in the receiver is never printed. What am I missing/doing incorrectly?
Here's the snippet where I tried (multiple ways) to broadcast a message, which is inside a class called IMService that extends Service:
//NEW_FRIEND_REQUEST is a String
Log.i( "MY_TAG", "broadcasting received friend request");
Intent i = new Intent( NEW_FRIEND_REQUEST, null, null, NotificationReceiver.class );
i.putExtra( USER_ID, user.username() );
sendBroadcast(i);
i = new Intent( NEW_FRIEND_REQUEST );
i.putExtra( USER_ID, user.username() );
sendBroadcast(i);
i = new Intent( this, NotificationReceiver.class );
i.putExtra( USER_ID, user.username() );
sendBroadcast(i);
The broadcast receiver (which is a standalone class aka not an inner class):
public class NotificationReceiver extends BroadcastReceiver
{
#Override
public void onReceive(Context context, Intent intent)
{
Log.i("MY_TAG", "friends broadcast receiver received a friend request message");
}
}
AndroidManifest.xml:
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<receiver android:name="NotificationsReceiver" >
<intent-filter>
<action android:name="IMService.NEW_FRIEND_REQUEST" />
</intent-filter>
</receiver>
<activity
android:name="activities.MainActivity"
android:configChanges="orientation|screenSize"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="activities.Login"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_login" >
</activity>
<activity
android:name="activities.Register"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_register" >
</activity>
<activity
android:name=".HttpRequest"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_signin" >
</activity>
<activity
android:name=".Messaging"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_messaging" >
</activity>
<service android:name=".IMService" />
<activity
android:name=".FriendList"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_friend_list" >
</activity>
<activity
android:name="activities.Home"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_home"
android:windowSoftInputMode="stateAlwaysHidden" >
</activity>
<activity
android:name="activities.Friends"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_friends"
android:windowSoftInputMode="stateAlwaysHidden" >
</activity>
<activity
android:name="activities.FriendRequests"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_friend_requests" >
</activity>
<activity
android:name="activities.PrivateChat"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_private_chat"
android:windowSoftInputMode="stateAlwaysHidden" >
</activity>
<activity
android:name="activities.RandomChat"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_random_chat" >
</activity>
<activity
android:name="activities.Groups"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_groups" >
</activity>
<activity
android:name="activities.GroupChat"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_group_chat"
android:windowSoftInputMode="stateAlwaysHidden" >
</activity>
<activity
android:name="activities.UserProfile"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_user_profile" >
</activity>
<activity
android:name=".Messages"
android:label="#string/title_activity_messages" >
</activity>
</application>
</manifest>
EDIT:
After reading Mike's comment, I tried the following 2 things (separately), but the receiver still does not receive the message:
<!-- no filter -->
<receiver android:name="NotificationReceiver" />
and:
<!-- with a filter, and I changed the value of NEW_FRIEND_REQUEST to
public static final String NEW_FRIEND_REQUEST = "new_friend_request"; -->
<receiver android:name="NotificationReceiver" >
<intent-filter>
<action android:name="new_friend_request" />
</intent-filter>
</receiver>
Here is my project's hierarchy:
Last Edit:
For anyone curious about the exact warning when I used a capital letter for the package name, here's a screen shot:
When using implicit Intents - i.e., Intents not created for a specific class - the action you're filtering for on the BroadcastReceiver must exactly match that which you use to create the Intent. In this case, the NEW_FRIEND_REQUEST String specified in the code did not match the <action> element in the manifest.
Also, when a Receiver is incorrectly listed in the manifest, firing an implicit Intent meant for it will fail silently, as the system won't be able find it. In this case, an extra s in NotificationReceiver was one problem. Another was that the Receiver is located in a subdirectory of /src, and therefore in a different package. This was corrected by changing the name listed in the manifest to include the subdirectory in the package name.
Finally, it appears that capital letters in package names - and, therefore, project directory names - can cause problems, and should be avoided.
I'm using GCM in my android application and when I try to register the device with GCM (with the command gcm.register(SENDER_ID)) I get the SEVICE_NOT_AVAILABLE error, I tried what someone suggested here (the accepted solution) and I did get the registration id.
Why is it like that?
Android manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.appspot.smartgan"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="com.appspot.smartgan.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.appspot.smartgan.permission.C2D_MESSAGE" />
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light" >
<activity
android:name="com.appspot.smartgan.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.appspot.smartgan" />
</intent-filter>
</receiver>
<service
android:name=".GcmIntentService"
android:enabled="true" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="com.appspot.smartgan.LoginActivity"
android:label="#string/title_activity_login"
android:windowSoftInputMode="adjustResize|stateVisible" >
</activity>
<activity
android:name="com.appspot.smartgan.ChildActivity"
android:label="#string/title_activity_child" >
</activity>
</application>
</manifest>
register method:
private void registerInBackground() {
new AsyncTask<Void, Void, String>() {
#Override
protected String doInBackground(Void... params) {
String message = "";
try {
if (gcm == null) {
gcm = GoogleCloudMessaging.getInstance(context);
}
regid = gcm.register(SENDER_ID);
message = "Device registered, registration ID=" + regid;
Log.d("SMARTGAN_PLAY", "register completed");
// send registration id to the server
sendRegistrationIdToServer();
// Persist the regID - no need to register again.
storeRegistrationId(context, regid);
} catch (IOException e) {
message = "Error:" + e.getMessage();
}
return message;
}
}.execute(null, null, null);
}
I think issue is regarding allowed IP addresses mentioned in your Google API project.
Please check details of the project and remove IP address if present under restrict use to IP address. I faced similar problem.
If you are receiving a Register ID it means you have registered the device successfully to the GCM.
Edit:
Here is a good tutorial for GCM: http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
<receiver
android:name="rockit.app.beardallstreetprimary.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="rockit.app.beardallstreetprimary" />
</intent-filter>
</receiver>
<service android:name="com.google.android.gcm.GCMIntentService" android:enabled="true" />
My GCM is set up based on the Tutorial i linked above so if you read through that aswell it should work for you it looks like your not far off. I will say the Manifest is very picky and you need to ensure that you link your Packages fully.
Also you dont need the Register Intent