From 94c88559cb17ffdd9e95c28c2509000f4ddb5be7 Mon Sep 17 00:00:00 2001 From: vantuan88291 Date: Tue, 12 Nov 2024 16:54:40 +0700 Subject: [PATCH] Update readme --- README.md | 25 +++++++++++++++++++++++++ RNhotupdate/README.md | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/README.md b/README.md index b949fc9..36d31fa 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,31 @@ Open `AppDelegate.m` and add this: #endif } ``` +#### For downloading in background mode on IOS, following this (optional): + +AppDelegate.h: +```bash +@property (nonatomic, assign) UIBackgroundTaskIdentifier taskIdentifier; +``` +AppDelegate.mm: + +```bash +- (void)applicationWillResignActive:(UIApplication *)application { + if (self.taskIdentifier != UIBackgroundTaskInvalid) { + [application endBackgroundTask:self.taskIdentifier]; + self.taskIdentifier = UIBackgroundTaskInvalid; + } + + __weak AppDelegate *weakSelf = self; + self.taskIdentifier = [application beginBackgroundTaskWithName:nil expirationHandler:^{ + if (weakSelf) { + [application endBackgroundTask:weakSelf.taskIdentifier]; + weakSelf.taskIdentifier = UIBackgroundTaskInvalid; + } + }]; +} +``` + ### Android Open `MainApplication.java/kt` and add these codes bellow: diff --git a/RNhotupdate/README.md b/RNhotupdate/README.md index b949fc9..36d31fa 100644 --- a/RNhotupdate/README.md +++ b/RNhotupdate/README.md @@ -36,6 +36,31 @@ Open `AppDelegate.m` and add this: #endif } ``` +#### For downloading in background mode on IOS, following this (optional): + +AppDelegate.h: +```bash +@property (nonatomic, assign) UIBackgroundTaskIdentifier taskIdentifier; +``` +AppDelegate.mm: + +```bash +- (void)applicationWillResignActive:(UIApplication *)application { + if (self.taskIdentifier != UIBackgroundTaskInvalid) { + [application endBackgroundTask:self.taskIdentifier]; + self.taskIdentifier = UIBackgroundTaskInvalid; + } + + __weak AppDelegate *weakSelf = self; + self.taskIdentifier = [application beginBackgroundTaskWithName:nil expirationHandler:^{ + if (weakSelf) { + [application endBackgroundTask:weakSelf.taskIdentifier]; + weakSelf.taskIdentifier = UIBackgroundTaskInvalid; + } + }]; +} +``` + ### Android Open `MainApplication.java/kt` and add these codes bellow: