public override void onReceive(Context context, Intent intent) { /* Once the application identifier is known */ if ("com.microsoft.azure.engagement.intent.action.APPID_GOT".Equals(intent.Action)) { /* Init the native push agent */ string appId = intent.getStringExtra("appId"); EngagementNativePushAgent.getInstance(context).onAppIdGot(appId); /* * Request GCM registration identifier, this is asynchronous, the response is made via a * broadcast intent with the <tt>com.google.android.c2dm.intent.REGISTRATION</tt> action. */ string sender = EngagementUtils.getMetaData(context).getString("engagement:gcm:sender"); if (sender != null) { /* Launch registration process */ Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER"); registrationIntent.Package = "com.google.android.gsf"; registrationIntent.putExtra("app", PendingIntent.getBroadcast(context, 0, new Intent(), 0)); registrationIntent.putExtra("sender", sender.Trim()); try { context.startService(registrationIntent); } catch (Exception) { /* Abort if the GCM service can't be accessed. */ } } } }
public override void onReceive(Context context, Intent intent) { /* Once the application identifier is known */ if ("com.microsoft.azure.engagement.intent.action.APPID_GOT".Equals(intent.Action)) { /* Init the native push agent */ string appId = intent.getStringExtra("appId"); EngagementNativePushAgent.getInstance(context).onAppIdGot(appId); /* * Request ADM registration identifier if enabled, this is asynchronous, the response is made * via a broadcast intent with the <tt>com.amazon.device.messaging.intent.REGISTRATION</tt> * action. */ if (EngagementUtils.getMetaData(context).getBoolean("engagement:adm:register")) { try { Type admClass = Type.GetType("com.amazon.device.messaging.ADM"); object adm = admClass.GetConstructor(typeof(Context)).newInstance(context); admClass.GetMethod("startRegister").invoke(adm); } catch (Exception) { /* Abort if ADM not available */ } } } }