You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb none #tests iOS / Android [CODEREVIEW] Andrew.Grant,Daniel.Lamb,Justin.Marcus [FYI] Pete.Sauerbrei #ROBOMERGE-SOURCE: CL 4898958 via CL 4898963 via CL 4898965 via CL 4905881 [CL 4906509 by thomas ross in Main branch]
56 lines
1.8 KiB
C++
56 lines
1.8 KiB
C++
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
|
|
#include "BackgroundHttpNotificationObject.h"
|
|
|
|
#include "LocalNotification.h"
|
|
|
|
FBackgroundHttpNotificationObject::FBackgroundHttpNotificationObject(FText InNotificationTitle, FText InNotificationBody, FText InNotificationAction, const FString& InNotificationActivationString, bool InNotifyOnlyOnFullSuccess)
|
|
: NotificationTitle(InNotificationTitle)
|
|
, NotificationAction(InNotificationAction)
|
|
, NotificationBody(InNotificationBody)
|
|
, NotificationActivationString(InNotificationActivationString)
|
|
, bNotifyOnlyOnFullSuccess(InNotifyOnlyOnFullSuccess)
|
|
, NumFailedDownloads(0)
|
|
, PlatformNotificationService(nullptr)
|
|
{
|
|
if (GConfig)
|
|
{
|
|
FString ModuleName;
|
|
GConfig->GetString(TEXT("LocalNotification"), TEXT("DefaultPlatformService"), ModuleName, GEngineIni);
|
|
|
|
if (ModuleName.Len() > 0)
|
|
{
|
|
// load the module by name from the .ini
|
|
if (ILocalNotificationModule* Module = FModuleManager::LoadModulePtr<ILocalNotificationModule>(*ModuleName))
|
|
{
|
|
PlatformNotificationService = Module->GetLocalNotificationService();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
FBackgroundHttpNotificationObject::~FBackgroundHttpNotificationObject()
|
|
{
|
|
if (nullptr != PlatformNotificationService)
|
|
{
|
|
if (!bNotifyOnlyOnFullSuccess || (NumFailedDownloads == 0))
|
|
{
|
|
//make a notification 1 second from now
|
|
FDateTime TargetTime = FDateTime::Now();
|
|
TargetTime += FTimespan::FromSeconds(1);
|
|
|
|
if (nullptr != PlatformNotificationService)
|
|
{
|
|
PlatformNotificationService->ScheduleLocalNotificationAtTime(TargetTime, true, NotificationTitle, NotificationBody, NotificationAction, NotificationActivationString);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void FBackgroundHttpNotificationObject::NotifyOfDownloadResult(bool bWasSuccess)
|
|
{
|
|
if (!bWasSuccess)
|
|
{
|
|
FPlatformAtomics::InterlockedIncrement(&NumFailedDownloads);
|
|
}
|
|
}
|