I'm trying to do some GCM notifications on Android. I've come as far as having something happen on the device.
NotificationService is throwing the following exception:
12-11 16:02:19.650 202-380/? E/NotificationService﹕ Ignoring notification with icon==0: Notification(contentView=org.***.**.reciever/0x1090098 vibrate=null,sound=null,defaults=0x0,flags=0x0)
Here is my manifest for reference:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.***.**.reciever"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="19" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<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="org.***.**.reciever.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="org.***.**.reciever.permission.C2D_MESSAGE" />
<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"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/***"
android:name=".***Application" >
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="org.***.**.reciever.MapActivity"
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="util.GcmBroadcastReciever"
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="org.***.**.reciever" />
</intent-filter>
</receiver>
<service android:name="util.GcmIntentService" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="***"/>
</application>
All the *. are just the masked package name, they are all the same.
Any idea what I'm doing wrong?
Also, is the notification supposed to pop up on the device without any extra code or does the app have to ask the OS to show a notification on the screen when the GCM push arrives? I think i read something about Android doing this part differently from iOS.
Figured it out, it's not the actual push message that's causing the issue as i thought. So i was barking up the wrong tree for a couple hours.
It turns out it was the actual notification that had an issue because it was demo code from Google >.<
Replaced with proper code -> working.
Thanks for your time!
Related
I saw many other questions on here saying if an app is force stopped it won't receive notifications.
However, I AM NOT force stopping this app. I am just hitting the back button. I have also tried just hitting the home button. In both cases no alerts.
However, if the app is running in the foreground the PushReceived event fires and the AData.Message shows the correct text. So, it would appear that remote notifications are being sent to the device, it's just that the app is never woken up to process them.
The app is written in Delphi XE8 and I have tested this on KitKat and JellyBean, both with the same results.
I suspect the problem is in the Android Manifest file. A copy of which is below. Beyond this I am not sure where to go. As I understand it when a push is received it is supposed to run a small bit of code in the Firemonkey framework that displays the push message without starting the full app.
I am using the app described in this tutorial to try to figure out why it is not working in my live app. This used to work as I expected it to in XE7.
http://docwiki.embarcadero.com/RADStudio/XE8/en/Mobile_Tutorial:_Using_Remote_Notifications_%28iOS_and_Android%29
I am using the Engagement Tab on the Kinvey dashboard to send the test pushes, so I assume the server side is correct. And as I said they are working with the app in the foreground.
Gary
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.gwsystemsdns.net.pushtest"
android:versionCode="1"
android:versionName="1.0.0"
android:installLocation="preferExternal">
<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="11" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission android:name="net.gwsystemsdns.net.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="net.gwsystemsdns.net.pushtest.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-feature android:glEsVersion="0x00020000" android:required="True"/>
<application android:persistent="False"
android:restoreAnyVersion="False"
android:label="PushTest"
android:debuggable="True"
android:largeHeap="False"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppTheme"
android:hardwareAccelerated="true">
<!-- Our activity is a subclass of the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="com.embarcadero.firemonkey.FMXNativeActivity"
android:label="PushTest"
android:configChanges="orientation|keyboard|keyboardHidden"
android:launchMode="singleTask">
<!-- Tell NativeActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="PushTest" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.embarcadero.firemonkey.notifications.FMXNotificationAlarm" />
<receiver android:exported="true" android:name="com.embarcadero.gcm.notifications.GCMNotification" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="net.gwsystemsdns.net.pushtest" />
</intent-filter>
</receiver>
</application>
</manifest>
<!-- END_INCLUDE(manifest) -->
My Push Received event demonstrating the reception of foreground pushes.
procedure TfrmMain.PushEvents1PushReceived(Sender: TObject; const AData: TPushData);
begin
Memo1.Lines.Add('Push Received');
Memo1.Lines.Add('Push = ' + AData.Message);
end;
I found the problem. This line was missing from the XE8 manifest template file:
<%activity%>
<service android:name="com.embarcadero.gcm.notifications.GCMIntentService" />
<%receivers%>
</application>
It goes into the AndroidManifest.template.xml file like this (immediately following the <%receivers%> tag:
<%activity%>
<service android:name="com.embarcadero.gcm.notifications.GCMIntentService" />
<%receivers%>
<receiver android:name="com.embarcadero.firemonkey.notifications.FMXNotificationAlarm" />
</application>
As per Embarcadero's docwiki.
i am using SCRINGO SDK in my android app....following are the screenshot for my app.. it is working fine but i am not getting notification when someone post , like or comment an activity , user messages .. i want to setup up alert ringtone or vibrate notification for that app so even when any user who is registered to the app got notifications on home screen with vibrate or alert tone (like ... user 4 likes your post.. you have a new message from user 2)...
i have tried using gcm services but its not working ... i have produced the app on google cloud got the project number and api key added it in scringo's dashboard.. and edited the mainfest but m not getting the desired result.... following is my mainfest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
package="com.scringo.friendz" >
<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.scringo.friendz.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="com.scringo.friendz.permission.C2D_MESSAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<permission android:name="com.scringo.friendz.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.scringo.friendz.permission.MAPS_RECEIVE"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<receiver android:name="com.scringo.push.ScringoGCMBroadcastReceiver" 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.scringo.friendz"/>
</intent-filter>
</receiver>
<service android:name="com.scringo.push.ScringoGCMIntentService"/>
<activity
android:label="#string/app_name"
android:name="com.scringo.friendz.MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="com.scringo.push.ScringoGCMBroadcastReceiver"
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.scringo.scringosample" />
</intent-filter>
</receiver>
<receiver android:name="com.scringo.friendz.MyReceiver">
<intent-filter>
<action android:name="com.scringo.LoginBroadcast" />
</intent-filter>
</receiver>
<service android:name="com.scringo.push.ScringoGCMIntentService" />
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyBx8aj7JrKh-rQAD96FgeAlf8-XFLc4ELc"/>
<activity
android:label="#string/title_activity_image_view"
android:name="com.scringo.friendz.ImageViewActivity" >
</activity>
</application>
</manifest>
Is it possible that you designated an IP address when setting up your server key (the instructions say to leave it blank, thus allowing all IPs)?
I followed the instructions provided by Scringo here exactly as written, and after successfully sending a test push message I started getting new message alerts when another user messaged me.
I have problems with GCMRegistrar, here is the code:
// Make sure the device has the proper dependencies.
GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this); <- this line is the problem (I suppose)
regId = GCMRegistrar.getRegistrationId(this);
When I change that line to a comment the app doesn't crash but the regId is empty, and when I try to use that line it makes my app crash, I don't know why so I hope you can help me. :)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.chattest1"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="com.example.chattest1.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.chattest1.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.chattest1.RegisAct"
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="com.example.chattest1.Main"
android:label="#string/title_activity_regis" >
</activity>
</application>
</manifest>
checkManifest checks if your manifest contains the definitions required for GCM to work.
It throws IllegalStateException when something is missing.
In your case, you are missing a broadcast receiver that can receive messages from GCM.
GCMRegistrar.getRegistrationId(this) (which returns a locally stored registration ID) will return a non-empty value only if you call GCMRegistrar.register first. Note that GCMRegistrar.register is non-blocking, so the response doesn't arrive immediately.
Finally, as CommonsWare suggested, GCMRegistrar is deprecated and you are encouraged to use GoogleClassMessaging class instead.
All,
Trying to use google v2 map api in my android application and can't get it to work, it keeps displaying a blank white page!
I even tried running samples from https://github.com/commonsguy/cw-omnibus/tree/master/MapsV2 and got the BasicMap application compiled and installed on my device but exactly same issue!
Since this is happening both for my code and this code that all I heard is a valid source I assume this is not the Key issue as these two use two different keys.
I've done all I could, here is manifest file from the sample:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.commonsware.android.mapsv2.basic"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16"/>
<permission
android:name="com.commonsware.android.mapsv2.basic.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<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"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.SET_DEBUG_APP" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock.Light.DarkActionBar">
<uses-library android:name="com.google.android.maps" />
<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.maps.v2.API_KEY"
android:value="AIzaSyC4iyT46cB00IdKGcy5EmAxK5uCOQX2Oy8"/>
<activity android:name="LegalNoticesActivity">
</activity>
</application>
</manifest>
Any idea what this could be?
Try to follow the following guide I wrote for adding a Google Map Api V2:
Google Map API V2
and please share you logcat stack trace with us so we could understand more clearly what is your problem.
My application is available in Android market and supported Android version 2.2+. But when i open Android market using Samsung SPH-M820 device. It doesn't show application in there. But when i enter full url and try to download app, It shows error message "app not compatible with your device". While device specifications are here.
What is the issue?
Update: Manifest file is added:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="packageName"
android:installLocation="auto"
android:versionName="Version1"
android:versionCode="10">
<uses-sdk android:minSdkVersion="8" />
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true" />
<!-- permissions -->
<permission android:name="packageName.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="packageName.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- This app has permission to register and receive message -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
<application android:icon="#drawable/icon" android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar" android:debuggable="false">
<receiver android:name=".PushIncidentReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<!-- Receive the actual message -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="packageName" />
</intent-filter>
<!-- Receive the registration id -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="packageName" />
</intent-filter>
</receiver>
<activity android:name=".SplashActivity" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>
That link doesn't look like it leads to any device specifications, but rather forum boards. In addition, what we really need is your AndroidManifest.xml file. While this response doesn't answer your question directly since we don't have access to your AndroidManifest.xml, hopefully this will help guide you or others to figure out what's wrong.
You can see what devices your application supports by logging on to your developer account at http://market.android.com/publish. Choose your application, and you will see the following section on the next page underneath "Publishing options":
That shows you requirements you have set up in the AndroidManifest.xml file of your application. In addition, you can even click "Show devices," and you will see a list of supported and unsupported devices for your application, such as the following:
You can see that my application doesn't support two HTC phones. In addition, you can even prevent specific phones that do meet your requirements by choosing to exclude them in the list.
If you want your application to work on a specific phone, you will have to modify your AndroidManifest.xml or application itself to have more lenient requirements so your phone can satisfy them.