dl1
dl1

Reputation: 25

Integrating Localytics - Project Number

I'm currently trying to integrate Localytics into my Android app. In step 5, they need a project number. How do I find this?

If you are using Localytics Push Messaging, register for push notifications in onCreate().
public void onCreate(Bundle savedInstanceState)
{
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);

   // If you're using Localytics Push Messaging 
   Localytics.registerPush("YOUR_PROJECT_NUMBER");

   // Activity Creation Code
}

Upvotes: 2

Views: 1410

Answers (2)

bitsabhi
bitsabhi

Reputation: 778

We had a long discussion with the localytics team, on how to integrate localytics to send and receive push notifications. I am sharing the working solution.

The PROJECT_NUMBER mentioned in the documentation(http://docs.localytics.com/) is same as SENDER_ID.

Also assuming you are following the automatic integration, if you wish the know the value sent against a key in the advanced section(Optional)(Could be the deep link url), you need to write your own custom receiver extending com.localytics.android.PushReceiver, define this in the manifest as well.

The value can be accessed as intent.getExtras().getString("key") in onReceive of your custom receiver.

Do not forget to initialize the default constructor and call super.onReceive(context,intent) in onReceive.

public class CustomReceiver extends PushReceiver {

private static final String TAG = PushReceiver.class.getSimpleName();

public CustomReceiver()
{
    super();
}

@Override
public void onReceive(Context context, Intent intent)
{
    super.onReceive(context,intent);

    Log.i(TAG, intent.getExtras().getString("key"));

}

}

<receiver
        android:name="yourpackagename.receivers.CustomReceiver"
        android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
            <action android:name="com.google.android.c2dm.intent.RECEIVE"/>

            <category android:name="yourpackagename"/>
        </intent-filter>
    </receiver>

Upvotes: 0

mrtn
mrtn

Reputation: 889

YOUR_PROJECT_NUMBER is your Google API Project Number.

Localytics Integration

Documentation - Create a Google API project and enable GCM

Upvotes: 2

Related Questions