• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by cdes · Jun 11, 2015 at 10:46 AM · android

Notification is received but not displayed using Parse Unity SDK + Android

I'm using Parse Unity SDK for Android.

I've managed to register the device successfully.

  void Start() {
         //Parse Installation
         if (ParseInstallation.CurrentInstallation != null && !string.IsNullOrEmpty(ParseInstallation.CurrentInstallation.DeviceToken))
         {
             Debug.Log("Device Token : " + ParseInstallation.CurrentInstallation.DeviceToken);
         }
         else
         {
             ParseInstallation installation = ParseInstallation.CurrentInstallation;
             installation.Channels = new List<string> { Config.Instance.GetUserInfo().GetEmail() };
             installation.SaveAsync().ContinueWith(t => {
                 if (t.IsFaulted || t.IsCanceled)
                 {
                     Debug.Log("Push subscription failed.");
                 }
                 else
                 {
                     Debug.Log("Push subscription success.");
                 }
             });
             
             
             //installation.
         }
     }

Only to discover that the notification is "received" but not being displayed neither in the app nor in the notifications bar.

     I/GCM     ( 1285): GCM message com.ahmed.app 0:1433935471473270%3f8fc5dbf9fd7ecd
     I/ParsePushService( 7057): Push notification received. Payload: {"alert":"test","push_hash":"098f6bcd4621d373cade4e832627b4f6"}
     I/ParsePushService( 7057): Push notification is handled while the app is foregrounded.
     W/GCM-DMM ( 1285): broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.ahmed.app (has extras) }

Also, Unity does not receive the notification (see code)

    void Awake() {
             ParsePush.ParsePushNotificationReceived += (sender, args) => {
                 #if UNITY_ANDROID
                 AndroidJavaClass parseUnityHelper = new AndroidJavaClass("com.parse.ParseUnityHelper");
                 AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
                 AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
     
                 //Debugging the payload
                 Debug.Log("Calling Parse from Unity and Payload is : " + args.StringPayload);
                 
                 // Call default behavior.
                 parseUnityHelper.CallStatic("handleParsePushNotificationReceived", currentActivity, args.StringPayload);
     
     
                 #endif
             };
         }

This event doesn't get triggered.

Here's my AndroidManifest.xml

     <?xml version="1.0" encoding="utf-8"?>
     <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ahmed.app" android:theme="@android:style/Theme.NoTitleBar" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal">
       <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
       
         <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
       <uses-feature android:glEsVersion="0x00020000" />
       <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="android.permission.WAKE_LOCK" />
       <uses-permission android:name="com.android.vending.BILLING" />
       <uses-permission android:name="android.permission.GET_ACCOUNTS" />
       <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
       <permission android:protectionLevel="signature" android:name="com.ahmed.app.permission.C2D_MESSAGE" />
       <uses-permission android:name="com.ahmed.app.permission.C2D_MESSAGE" />
       
       <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false">
         <activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
           <intent-filter>
             <action android:name="android.intent.action.MAIN" />
             <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
           <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
           <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
         </activity>
         <meta-data android:name="com.google.android.gms.version" android:value="4030500" />
         <activity android:name="com.outlinegames.unibill.PurchaseActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />       
         <service android:name="com.parse.ParsePushService" /> 
         <receiver android:name="com.parse.ParsePushBroadcastReceiver" 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.ahmed.app" />
               </intent-filter>
         </receiver>
     
       </application>
    </manifest>

Any idea what's the problem?

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image beQr86 · Jul 02, 2015 at 10:11 AM 0
Share

did you manage to find a solution to your problem ?

avatar image OmgTear · Jul 03, 2015 at 06:20 PM 0
Share

got the same problem, $$anonymous$$essage received correctly but not displayed

In logs: 07-03 21:17:48.823: I/ParsePushService(2652): Push notification received. Payload: {"alert":"A test push from Parse!","push_hash":"2bf06f5e2a92eab2fcb855fc1117fa33"} 07-03 21:17:48.823: I/ParsePushService(2652): Push notification is handled while the app is foregrounded.

avatar image omrip3 · Aug 27, 2015 at 06:05 PM 0
Share

Can you please upload your new code. I have the same issues and anything that I do, doesn't solve it.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by cdes · Jul 04, 2015 at 05:13 AM

Rather than downloading the SDK manually, I've downloaded the Parse Push sample project and copied the files to my project. Using the SDK 1.5.2 sample project, it works now.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity Android Error on rigidbody.AddForce? 0 Answers

JDK home issue (Mac to android) 0 Answers

Jittery models in Google Cardboard App made in Unity 0 Answers

Why an empty project jumping 20 - 120 fps on android? 2 Answers

What is needed to develop on Android? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges