跳转至

Unreal

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

安卓

本节描述了 Android 所需的设置。

选择推送服务

  1. 在虚幻编辑器中,点击菜单中的 编辑 > 项目设置。项目设置窗口将出现。
  2. 在项目设置窗口的左侧面板中,点击 Hive SDK 下的 依赖项 – Android
  3. Hive SDK 依赖项 – Android 屏幕的右侧窗格中,在推送部分选择要用于 推送类型 的推送服务。例如,如果您使用的是 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<NSString*, id> * 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<NSString*, id> *)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 控制台中注册它