Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to integrate parse into my app with push notifications and have the notification display custom text and open the device's browser when I send a url to it.

The parse integration is fine(Thats the easy part) but where I am stuck is what to code for the integration for handling the json code sent by the parse interface and have the app translate it into the action I need done.

I know I will have to update the manifest file and the main activity class to accomplish this but I am stuck.

share|improve this question

1 Answer 1

Add Manifest to

<receiver android:name="com.sample.app.android.recevier.PushNotificationRecevier" >
   <intent-filter>
     <action android:name="com.sample.app.android.SIMPLE_NOTIFICATION" />
   </intent-filter>
</receiver>

Create One receiver Class

import org.json.JSONException;
import org.json.JSONObject;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class PushNotificationRecevier extends BroadcastReceiver{
    String SimpleNotification="com.sample.app.android.SIMPLE_NOTIFICATION";
    @Override
    public void onReceive(Context context, Intent intent) {
        if(intent.getAction().equalsIgnoreCase(SimpleNotification)){

            // Your Stuff 
JSONObject jsonObject=new JSONObject(intent.getExtras().getString("com.parse.Data"));


        }
    }
}
share|improve this answer
    
Ok got that, but not sure what to put in the "Your Stuff" area. I know it has to decode the json query(Which I will have toy research how to construct as I am still new to java and json). But also getting errors about: Broadcast Receiver, Context and Intent cannot be resolved to a type. –  JRod Oct 16 '14 at 12:26
    
check my latest –  SelvaMariappan Oct 16 '14 at 12:28
    
u can use JSONObject jsonObject=new JSONObject(intent.getExtras().getString("com.parse.Data")); form get json Object then u can parse ur own way. –  SelvaMariappan Oct 16 '14 at 12:29
    
Ok got that validated finally with a lot of checks from eclipse. Nw for the JSON code. I want to be able to send text and a url for the push to open in browser. In your code I only see appID, packageName and versionCode. I can pass these but what should I pass to send custom title, text and url. Something Like This: { “title”: “You Have a New Message”, “alert": “Here is some text”, “url”: “someurl.com” } –  JRod Oct 16 '14 at 12:40
    
yes ur right :) –  SelvaMariappan Oct 16 '14 at 12:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.