Name of the variant: No installation yet

We are half way there! Use the code snippet bellow to register your device and allow it to receiving notifications through this UnifiedPush Server. If you don't know how to do this, go to the documentation for full sept by step explanation.

  1. Copy the code snippet and paste it on your device code.
  2. Build and deploy your app.
  3. Click Continue (Bellow)
Copy
package com.push.pushapplication;

import java.net.URI;
import java.net.URISyntaxException;

import org.jboss.aerogear.android.unifiedpush.PushConfig;
import org.jboss.aerogear.android.unifiedpush.PushRegistrar;
import org.jboss.aerogear.android.unifiedpush.Registrations;

import android.app.Application;

public class PushApplication extends Application {

    private final String VARIANT_ID       = "7d37fd1a-82c1-48c8-be94-6456f26075fc";
    private final String SECRET           = "c6dc8b14-0c6f-4f41-8835-2a87827ee1f4";
    private final String GCM_SENDER_ID    = "33";
    private final String UNIFIED_PUSH_URL = "http://localhost:8080/ag-push/";

    private PushRegistrar registration;

    @Override
    public void onCreate() {
        super.onCreate();

        Registrations registrations = new Registrations();

        try {
            PushConfig config = new PushConfig(new URI(UNIFIED_PUSH_URL), GCM_SENDER_ID);
            config.setVariantID(VARIANT_ID);
            config.setSecret(SECRET);
            config.setAlias(MY_ALIAS);

            registration = registrations.push("unifiedpush", config);

            registration.register(getApplicationContext(), new Callback() {
                private static final long serialVersionUID = 1L;

                @Override
                public void onSuccess(Void ignore) {
                     Toast.makeText(MainActivity.this, "Registration Succeeded!",
                             Toast.LENGTH_LONG).show();
               }

               @Override
               public void onFailure(Exception exception) {
                     Log.e("MainActivity", exception.getMessage(), exception);
               }
            });

        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }
}

Next we are going to send a test notification. Make sure you build or deploy your app after pasting the snnipet.