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       = "{{ variant.variantID }}";
    private final String SECRET           = "{{ variant.secret }}";
    private final String GCM_SENDER_ID    = "{{ variant.projectNumber }}";
    private final String UNIFIED_PUSH_URL = "{{ contextPath }}";

    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);
        }
    }
}

@@ -39,52 +39,52 @@
 ort 
-java.net.URI;%0Aimport java.net.URISyntaxExcep
+android.util.Log;%0Aimport android.app.Applica
 tion
@@ -124,30 +124,21 @@
 oid.
-unifiedpush.PushConfig
+core.Callback
 ;%0Aim
@@ -254,41 +254,91 @@
 stra
-tions;%0A%0Aimport android.app.Applic
+rManager;%0Aimport org.jboss.aerogear.android.unifiedpush.gcm.AeroGearGCMPushConfigur
 atio
@@ -677,49 +677,8 @@
 %22;%0A%0A
-    private PushRegistrar registration;%0A%0A
     
@@ -763,51 +763,71 @@
 stra
-tions registrations = new Registrations();%0A
+rManager.config(%22register%22, AeroGearGCMPushConfiguration.class)
 %0A   
@@ -835,14 +835,9 @@
     
-try %7B%0A
+ 
     
@@ -847,71 +847,90 @@
     
- PushConfig config = new PushConfig(new URI(UNIFIED_PUSH_URL), 
+.setPushServerURI(URI.create(UNIFIED_PUSH_URL))%0A                    .setSenderIds(
 GCM_
@@ -935,25 +935,24 @@
 M_SENDER_ID)
-;
 %0A           
@@ -948,30 +948,32 @@
             
-config
+        
 .setVariantI
@@ -985,18 +985,21 @@
 IANT_ID)
-;
 %0A
+    
         
@@ -998,30 +998,28 @@
             
-config
+    
 .setSecret(S
@@ -1024,17 +1024,16 @@
 (SECRET)
-;
 %0A       
@@ -1041,47 +1041,54 @@
     
-config.setAlias(MY_ALIAS);%0A%0A           
+        .asRegistrar();%0A%0A        PushRegistrar
  reg
@@ -1096,67 +1096,63 @@
 stra
-tion = r
+r = R
 egistra
-tions.push(%22unifiedpush%22, config
+rManager.getRegistrar(%22register%22
 );%0A
-%0A
         
     
@@ -1151,20 +1151,16 @@
     
-    
 registra
 tion
@@ -1155,20 +1155,17 @@
 registra
-tion
+r
 .registe
@@ -1207,83 +1207,19 @@
 back
-() %7B%0A                private static final long serialVersionUID = 1L;%0A%0A    
+%3CVoid%3E() %7B%0A
     
@@ -1228,36 +1228,32 @@
       @Override%0A
-    
             publ
@@ -1279,14 +1279,12 @@
 oid 
-ignore
+data
 ) %7B%0A
@@ -1303,133 +1303,47 @@
     
-     Toast.makeText(MainActivity.this, %22Registration Succeeded!%22,%0A                             Toast.LENGTH_LONG).show();%0A   
+Log.i(TAG, %22Registration Succeeded!%22);%0A
     
@@ -1357,35 +1357,32 @@
  %7D%0A%0A            
-   
 @Override%0A      
@@ -1367,35 +1367,32 @@
       @Override%0A
-   
             publ
@@ -1424,25 +1424,12 @@
 on e
-xception) %7B%0A     
+) %7B%0A
     
@@ -1450,22 +1450,11 @@
 g.e(
-%22MainActivity%22
+TAG
 , ex
@@ -1503,23 +1503,18 @@
     
-   %7D%0A  
+%7D%0A
         
   %7D)
@@ -1513,109 +1513,13 @@
     
-  
 %7D);%0A%0A
-        %7D catch (URISyntaxException e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A
     

Update Android registration code snippet