Unreal
Hive SDK Unreal Engine provides settings for using notification features.
Android¶
This section describes the necessary settings for Android.
Selecting a push service¶
- In Unreal Editor, click Edit > Project Settings in the menu. The Project Settings window appears.
- In the left panel of the Project Settings window, click Dependency – Android under Hive SDK.
- In the right pane of the Hive SDK Dependency – Android screen, select the push service to use for Push Type in the Push section. For example, if you are using Firebase Cloud Messaging, select Google FCM.
Hive console settings: remote push¶
To use Remote Push, you must obtain a Push certificate from Google or Apple Console and register it in the Hive console.
iOS¶
This section describes the necessary settings for iOS.
Selecting a push service¶
Unreal iOS includes Apple Push Notification Service by default.
Modifying Unreal Engine¶
To use the notification feature provided by Hive SDK, you need to modify Unreal Engine. Add the lines between the Add
and Add End
comments or the lines with the Add
comment in the files below.
Engine/Source/Runtime/ApplicationCore/Public/IOS/IOSAppDelegate.h
DECLARE_MULTICAST_DELEGATE_FourParams(FOnOpenURL, UIApplication*, NSURL*, NSString*, id);
static FOnOpenURL OnOpenURL;
// Add
DECLARE_MULTICAST_DELEGATE_ThreeParams(FOnOpenURLwithOptions, UIApplication*, NSURL*, NSDictionary* );
static FOnOpenURLwithOptions OnOpenURLwithOptions;
// Add End
// parameters passed from openURL
@property (nonatomic, retain) NSMutableArray* savedOpenUrlParameters;
@property (nonatomic, retain) NSMutableArray* savedOpenUrlWithOptionsParameters; // Add
Engine/Source/Runtime/ApplicationCore/Private/IOS/IOSAppDelegate.cpp
extern bool GShowSplashScreen;
FIOSCoreDelegates::FOnOpenURL FIOSCoreDelegates::OnOpenURL;
FIOSCoreDelegates::FOnOpenURLwithOptions FIOSCoreDelegates::OnOpenURLwithOptions; // Add
FIOSCoreDelegates::FOnWillResignActive FIOSCoreDelegates::OnWillResignActive;
FIOSCoreDelegates::FOnDidBecomeActive FIOSCoreDelegates::OnDidBecomeActive;
TArray FIOSCoreDelegates::PushNotificationFilters;
@synthesize AccessibilityCacheTimer;
#endif
@synthesize savedOpenUrlParameters;
@synthesize savedOpenUrlWithOptionsParameters; // Add
@synthesize BackgroundSessionEventCompleteDelegate;
GShowSplashScreen = false;
}, TStatId(), NULL, ENamedThreads::ActualRenderingThread);
}
// Add
for (NSDictionary* openUrlParameter in self.savedOpenUrlWithOptionsParameters)
{
UIApplication* application = [openUrlParameter valueForKey : @"application"];
NSURL* url = [openUrlParameter valueForKey : @"url"];
NSDictionary \* options = [openUrlParameter valueForKey : @"options"];
FIOSCoreDelegates::OnOpenURLwithOptions.Broadcast(application, url, options);
}
self.savedOpenUrlWithOptionsParameters = nil; // clear after saved openurl delegate running
// Add End
for (NSDictionary\* openUrlParameter in self.savedOpenUrlParameters)
{
UIApplication\* application = [openUrlParameter valueForKey : @"application"];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
// save launch options
self.launchOptions = launchOptions;
#if PLATFORM_TVOS
self.bDeviceInPortraitMode = false;
#else
// use the status bar orientation to properly determine landscape vs portrait
self.bDeviceInPortraitMode = UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]);
printf("========= This app is in %s mode\n", self.bDeviceInPortraitMode ? "PORTRAIT" : "LANDSCAPE");
#endif
// check OS version to make sure we have the API
OSVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
if (!FPlatformMisc::IsDebuggerPresent() || GAlwaysReportCrash)
{
// InstallSignalHandlers();
}
self.savedOpenUrlParameters = [[NSMutableArray alloc] init];
self.savedOpenUrlWithOptionsParameters = [[NSMutableArray alloc] init]; // Add
self.PeakMemoryTimer = [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(RecordPeakMemory) userInfo:nil repeats:YES];
#if !BUILD_EMBEDDED_APP
return YES;
}
// Add
//# Use option
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary \*)options
{
#if !NO\_LOGGING
NSLog(@"%s", "IOSAppDelegate openURL options\n");
#endif
NSString\* EncdodedURLString = [url absoluteString];
NSString\* URLString = [EncdodedURLString stringByRemovingPercentEncoding];
FString CommandLineParameters(URLString);
// Strip the "URL" part of the URL before treating this like args. It comes in looking like so:
// "MyGame://arg1 arg2 arg3 ..."
// So, we're going to make it look like:
// "arg1 arg2 arg3 ..."
int32 URLTerminator = CommandLineParameters.Find( TEXT("://"), ESearchCase::CaseSensitive);
if ( URLTerminator > -1 )
{
CommandLineParameters.RightChopInline(URLTerminator + 3, false);
}
FIOSCommandLineHelper::InitCommandArgs(CommandLineParameters);
self.bCommandLineReady = true;
[self.CommandLineParseTimer invalidate];
self.CommandLineParseTimer = nil;
// Save openurl infomation before engine initialize.
// When engine is done ready, running like previous. ( if OnOpenUrl is bound on game source. )
if (bEngineInit)
{
FIOSCoreDelegates::OnOpenURLwithOptions.Broadcast(app, url, options);
}
else
{
#if !NO\_LOGGING
NSLog(@"%s", "Before Engine Init receive IOSAppDelegate openURL\n");
#endif
NSDictionary\* openUrlParameter = [NSDictionary dictionaryWithObjectsAndKeys :
app , @"application",
url, @"url",
options, @"options",
nil];
[savedOpenUrlWithOptionsParameters addObject : openUrlParameter];
}
return YES;
}
// Add End
FCriticalSection RenderSuspend;
- (void)applicationWillResignActive:(UIApplication \*)application
{
Hive console settings: remote push¶
To use Remote Push, you must obtain a Push certificate from Google or Apple Console and register it in the Hive console.