跳轉至

Unreal

Hive SDK Unreal Engine 提供了使用通知功能的設置。

安卓

本節描述了 Android 所需的設置。

選擇推送服務

  1. 在 Unreal Editor 中,点击菜单中的 Edit > Project Settings。项目设置窗口将出现。
  2. 在项目设置窗口的左侧面板中,点击 Hive SDK 下的 Dependency – Android
  3. Hive SDK Dependency – Android 屏幕的右侧面板中,在推送部分选择要用于 Push Type 的推送服务。例如,如果您使用的是 Firebase Cloud Messaging,请选择 Google FCM

Hive 控制台設定:遠端推送

要使用遠程推送,您必須從 Google 或 Apple 控制台獲取推送證書並 在 Hive 控制台中註冊它

iOS

本節描述了 iOS 所需的設置。

選擇推送服務

Unreal iOS 預設包含 Apple 推播通知服務。

修改虛幻引擎

要使用 Hive SDK 提供的通知功能,您需要修改虚幻引擎。在下面的文件中,在 AddAdd End 注释之间或带有 Add 注释的行中添加行。


引擎/源代码/运行时/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

引擎/源代码/运行时/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 控制台設置:遠程推送

要使用遠程推送,您必須從 Google 或 Apple 控制台獲取推送證書,並在 Hive 控制台中註冊它