For more information please look at: https://digitalclub.atlassian.net/wiki/spaces/N/pages/2983854102/Force+Flexible+update+flow+for+apps?focusedCommentId=3025272837
You can load in the endpoint by adding the following to your app module:
AppUpdateModule.forRoot({
androidMaximumFlexibleVersion: Config.ANDROID_MAXIMUM_FLEXIBLE_VERSION,
androidMinimalSupportedVersion: Config.ANDROID_MINIMAL_SUPPORTED_VERSION,
iosMaximumFlexibleVersion: Config.IOS_MAXIMUM_FLEXIBLE_VERSION,
iosMinimalSupportedVersion: Config.IOS_MINIMAL_SUPPORTED_VERSION,
}),
Make sure to also setup your config file, for example:
export const Config = {
ANDROID_MAXIMUM_FLEXIBLE_VERSION:
process.env.ANDROID_MAXIMUM_FLEXIBLE_VERSION ?? '1.0.0',
ANDROID_MINIMAL_SUPPORTED_VERSION:
process.env.ANDROID_MINIMAL_SUPPORTED_VERSION ?? '1.0.0',
IOS_MAXIMUM_FLEXIBLE_VERSION:
process.env.IOS_MAXIMUM_FLEXIBLE_VERSION ?? '1.0.0',
IOS_MINIMAL_SUPPORTED_VERSION:
process.env.IOS_MINIMAL_SUPPORTED_VERSION ?? '1.0.0',
};
Alternatively, if you need a custom endpoint you can make use of the AppUpdateService. For example:
import { Controller, Get, HttpCode, HttpStatus, Query } from '@nestjs/common';
import { ApiOkResponse, ApiOperation } from '@nestjs/swagger';
import {
AppUpdateService,
AppVersionStateDto,
CheckAppVersionDto,
} from 'nestjs-app-update';
import Config from '../../../../config/config';
@Controller()
export class OwnerAppUpdateController {
constructor(private readonly appUpdateService: AppUpdateService) {}
@Get('/owner/version/status')
@ApiOperation({
summary: 'Get the state of your version for a specific platform',
})
@ApiOkResponse({ description: 'The version state', type: AppVersionStateDto })
@HttpCode(HttpStatus.OK)
public async checkVersionStatus(
@Query() dto: CheckAppVersionDto,
): Promise<AppVersionStateDto> {
return this.appUpdateService.checkVersionStatus(dto, {
androidMaximumFlexibleVersion:
Config.OWNER_ANDROID_MAXIMUM_FLEXIBLE_VERSION,
androidMinimalSupportedVersion:
Config.OWNER_ANDROID_MINIMAL_SUPPORTED_VERSION,
iosMaximumFlexibleVersion: Config.OWNER_IOS_MAXIMUM_FLEXIBLE_VERSION,
iosMinimalSupportedVersion: Config.OWNER_IOS_MINIMAL_SUPPORTED_VERSION,
});
}
}
When using this custom implementation make sure to also define a module for it:
import { Module } from '@nestjs/common';
import { AppUpdateService } from 'nestjs-app-update';
import { OwnerAppUpdateController } from './owner-app-update.controller';
@Module({
providers: [AppUpdateService],
controllers: [OwnerAppUpdateController],
})
export class OwnerAppUpdateModule {}