You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#jira UE-104943 #ue5 #android #review @Jack.Porter #rb Jack.Porter [CL 15284943 by Chris Babcock in ue5-main branch]
47 lines
1.5 KiB
Java
47 lines
1.5 KiB
Java
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
package com.epicgames.unreal;
|
|
|
|
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.unreal.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 );
|
|
}
|
|
}
|