Android Push Notification Don't Open App When Tapped

Hi, I’m using Pushwoosh to send GCM push notifications to my Android app (built with Corona Enterprise).

When my app is not in the foreground, tapping notifications I receive from it does not bring it to the foreground.

Is this behavior something that should

  • be automatically handled by the OS?

  • be automatically handled by Corona?

  • be custom written by me?

I believe I’m using a fairly stock AndroidManifest.xml with few modifications. Here it is for reference:

\<?xml version="1.0" encoding="utf-8"?\> \<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.cre8d.myapp" android:versionCode="1" android:versionName="1.0" android:installLocation="auto"\> \<!-- Set the minimum and target Android API levels here to inform the app store what OS versions this app supports. Set the "minSdkVersion" to at least API level 10 (aka: Android 2.3.3 "Gingerbread") which is the minimum Corona supports. Set the "targetSdkVersion" to the API level that you compile with. Set to a high level to avoid compatibility mode. --\> \<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="16"/\> \<!-- Permissions required by this app. --\> \<uses-permission android:name="android.permission.INTERNET"/\> \<uses-permission android:name="android.permission.VIBRATE"/\> \<uses-permission android:name="android.permission.GET\_ACCOUNTS"/\> \<uses-permission android:name="android.permission.RECEIVE\_BOOT\_COMPLETED"/\> \<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/\> \<uses-permission android:name=".permission.C2D\_MESSAGE"/\> \<uses-permission android:name="android.permission.CAMERA"/\> \<uses-permission android:name="android.permission.WRITE\_EXTERNAL\_STORAGE"/\> \<uses-permission android:name="android.permission.READ\_CONTACTS"/\> \<!-- Informs the app store that this app requires OpenGL ES 2.0 as a minimum. Required by Corona. --\> \<uses-feature android:glEsVersion="0x00020000"/\> \<!-- Informs the app store what features are required or are optional for this app. --\> \<!-- Setting the telephony feature to not required allows this app to be installed by devices that are not phones. --\> \<uses-feature android:name="android.hardware.telephony" android:required="false"/\> \<!-- Provides information about this app. The "name" attribute should be set to the name of the class that extends/inherits from the Application class. The "label" attribute sets the name of the application as how it is shown to the end-user. --\> \<application android:name="CoronaApplication" android:label="My App" android:hardwareAccelerated="true" android:debuggable="true" android:icon="@drawable/ic\_launcher"\> \<!-- The main Corona activity that runs the Corona project. --\> \<activity android:name="com.ansca.corona.CoronaActivity" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation|screenSize" android:label="My App" android:launchMode="singleTask" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"\> \<intent-filter\> \<action android:name="android.intent.action.MAIN" /\> \<category android:name="android.intent.category.LAUNCHER" /\> \</intent-filter\> \</activity\> \<!-- Other Corona activities that can be launched by the main Corona activity. --\> \<activity android:name="com.ansca.corona.CameraActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:configChanges="keyboardHidden|orientation|screenSize" android:screenOrientation="portrait" /\> \<activity android:name="com.ansca.corona.VideoActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:configChanges="keyboardHidden|orientation|screenSize" /\> \<activity android:name="com.ansca.corona.purchasing.StoreActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:configChanges="keyboardHidden|screenSize|orientation" /\> \<!-- Corona content provider required by the video player and mail app to access this app's local files. --\> \<provider android:name="com.ansca.corona.storage.FileContentProvider" android:authorities="com.cre8d.myapp.files" android:exported="true" /\> \<!-- Corona service used to perform background operations such as managing notifications. --\> \<service android:name="com.ansca.corona.CoronaService" /\> \<!-- Receiver which automatically starts this application after the Android device starts up. This is needed to show this application's active status bar notifications and reschedule pending notifications after the device boots up, because they will only be shown if the app is running. This receiver only works if the "android.permission.RECEIVE\_BOOT\_COMPLETED" permission has been set. --\> \<receiver android:name="com.ansca.corona.SystemStartupBroadcastReceiver"\> \<intent-filter\> \<action android:name="android.intent.action.BOOT\_COMPLETED" /\> \</intent-filter\> \</receiver\> \<!-- Handles local/scheduled notification events. --\> \<receiver android:name="com.ansca.corona.notifications.AlarmManagerBroadcastReceiver" /\> \<receiver android:name="com.ansca.corona.notifications.StatusBarBroadcastReceiver" /\> \<!-- Listens for Google Cloud Messaging push notifications and registration messages. --\> \<receiver android:name="com.ansca.corona.notifications.GoogleCloudMessagingBroadcastReceiver" 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.cre8d.myapp" /\> \</intent-filter\> \</receiver\> \<!-- Listens for Google Play/Marketplace in-app purchase responses and notifications. --\> \<receiver android:name="com.ansca.corona.purchasing.GoogleStoreBroadcastReceiver"\> \<intent-filter\> \<action android:name="com.android.vending.billing.IN\_APP\_NOTIFY" /\> \<action android:name="com.android.vending.billing.RESPONSE\_CODE" /\> \<action android:name="com.android.vending.billing.PURCHASE\_STATE\_CHANGED" /\> \</intent-filter\> \</receiver\> \<!-- Required by the Facebook library. --\> \<!-- Uncomment the below if your app uses this library. --\> \<!-- \<activity android:name="com.facebook.LoginActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:configChanges="keyboardHidden|screenSize|orientation"/\> \<activity android:name="com.ansca.corona.facebook.FacebookFragmentActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:configChanges="keyboardHidden|screenSize|orientation"/\> --\> \</application\> \</manifest\>

Any help is much appreciated. Thanks in advance!

Ben

First, I would recommend that you start with a much simpler test to verify that your GCM set up is correct.

Our Corona Simulator contains a sample project “Notifications/GooglePushNotifications” which pushes a GCM notification to itself.  I recommend that you build this sample project via the Corona Simulator and verify that you can get it to work first without PushWoosh.  You’ll need to modify the following parts in this project to get it to work:

  • config.lua:  Set the project number string here.  This is also known as the “Sender ID”.  This is needed to register the app with the GCM servers in order to receive notifications.
  • main.lua:  Set the “googleApiKey” and “googleRegistrationId” variables needed to send the push notification to the GCM server.

Once you’ve verified that this sample app works with your app’s GCM IDs, copy the above Corona project’s files to your Android app project’s “assets” directory and verify that it’ll work for a Corona Enterprise built app.

Hopefully the above will help you isolate the issue.  I’m thinking odds are you’ve either forgotten to set the Google project number in Corona’s “config.lua” file or it’s an issuing on the PushWoosh side.

I hope this helps.

First, I would recommend that you start with a much simpler test to verify that your GCM set up is correct.

Our Corona Simulator contains a sample project “Notifications/GooglePushNotifications” which pushes a GCM notification to itself.  I recommend that you build this sample project via the Corona Simulator and verify that you can get it to work first without PushWoosh.  You’ll need to modify the following parts in this project to get it to work:

  • config.lua:  Set the project number string here.  This is also known as the “Sender ID”.  This is needed to register the app with the GCM servers in order to receive notifications.
  • main.lua:  Set the “googleApiKey” and “googleRegistrationId” variables needed to send the push notification to the GCM server.

Once you’ve verified that this sample app works with your app’s GCM IDs, copy the above Corona project’s files to your Android app project’s “assets” directory and verify that it’ll work for a Corona Enterprise built app.

Hopefully the above will help you isolate the issue.  I’m thinking odds are you’ve either forgotten to set the Google project number in Corona’s “config.lua” file or it’s an issuing on the PushWoosh side.

I hope this helps.