Files
UnrealEngineUWP/Engine/Plugins/Runtime/GoogleCloudMessaging/Source/Java/RemoteNotificationsRegistrationIntentService.java
Ben Marsh 7598af0532 Update copyright notices to 2019.
#rb none
#lockdown Nick.Penwarden

[CL 4662404 by Ben Marsh in Main branch]
2018-12-14 13:41:00 -05:00

47 lines
1.5 KiB
Java

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
package com.epicgames.ue4;
import java.io.IOException;
import android.app.IntentService;
import android.content.Intent;
import com.google.android.gms.iid.InstanceID;
import com.google.android.gms.gcm.GoogleCloudMessaging;
import com.google.android.gms.gcm.GcmPubSub;
public class RemoteNotificationsRegistrationIntentService extends IntentService
{
public RemoteNotificationsRegistrationIntentService()
{
super( "com.epicgames.ue4.RemoteNotificationsRegistrationIntentService" );
}
public RemoteNotificationsRegistrationIntentService( String name )
{
super( name );
}
@Override
protected void onHandleIntent( Intent intent )
{
try
{
InstanceID instanceID = InstanceID.getInstance( GameActivity._activity.getApplicationContext() );
String Token = instanceID.getToken( GameActivity._activity.GCMSenderId, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null );
// subscribe to default topic: /topics/global
subscribeTopics( Token );
GameActivity._activity.nativeGCMRegisteredForRemoteNotifications( Token );
}
catch( Exception e )
{
GameActivity._activity.nativeGCMFailedToRegisterForRemoteNotifications( "Failed to complete token refresh" );
}
}
private void subscribeTopics( String token ) throws IOException {
GcmPubSub pubSub = GcmPubSub.getInstance( GameActivity._activity.getApplicationContext() );
pubSub.subscribe( token, "/topics/global", null );
}
}