Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload the ipa files for the iOS platform #583

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions res/app/components/stf/app-state/app-state-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module.exports = function AppStateProvider() {
},
user: {
settings: {}
},
device: {
platform: ''
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,15 @@ module.exports = function EnhanceDeviceServiceFactory($filter, AppState) {
return url
}

function enhanceDeviceAppState(device) {
AppState.device.platform = device.platform
}

service.enhance = function(device) {
setState(device)
enhanceDevice(device)
enhanceDeviceDetails(device)
enhanceDeviceAppState(device)
}

return service
Expand Down
58 changes: 36 additions & 22 deletions res/app/components/stf/install/install-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = function InstallService(
, $http
, $filter
, StorageService
, AppState
) {
var installService = Object.create(null)

Expand Down Expand Up @@ -71,9 +72,9 @@ module.exports = function InstallService(
installation.update(uploadResult.progress / 2, uploadResult.lastData)
installation.manifest = uploadResult.body
return control.install({
href: installation.href
, manifest: installation.manifest
, launch: installation.launch
href: installation.href,
manifest: installation.manifest,
launch: installation.launch
})
.progressed(function(result) {
installation.update(50 + result.progress / 2, result.lastData)
Expand All @@ -89,12 +90,13 @@ module.exports = function InstallService(

installService.installFile = function(control, $files) {
var installation = new Installation('uploading')
let isIOSPlatform = AppState.device.platform === 'iOS'
$rootScope.$broadcast('installation', installation)
return StorageService.storeFile('apk', $files, {
filter: function(file) {
return /\.(apk|aab)$/i.test(file.name)
return isIOSPlatform ? /\.(ipa)$/i.test(file.name) : /\.(apk|aab)$/i.test(file.name)
}
})
})
.progressed(function(e) {
if (e.lengthComputable) {
installation.update(e.loaded / e.total * 100 / 2, 'uploading')
Expand All @@ -103,31 +105,43 @@ module.exports = function InstallService(
.then(function(res) {
installation.update(100 / 2, 'processing')
installation.href = res.data.resources.file.href
return $http.get(installation.href + '/manifest')
.then(function(res) {
if (res.data.success) {
installation.manifest = res.data.manifest
return control.install({
href: installation.href
, manifest: installation.manifest
, launch: installation.launch
})
.progressed(function(result) {
installation.update(50 + result.progress / 2, result.lastData)
})
}
else {
throw new Error('Unable to retrieve manifest')
}
if(isIOSPlatform) {
installation.manifest = {'application': {'activities': {}}}
return control.install({
href: installation.href,
manifest: installation.manifest,
launch: installation.launch
})
.progressed(function(result) {
installation.update(50 + result.progress / 2, result.lastData)
})
} else {
return $http.get(installation.href + '/manifest')
.then(function(res) {
if (res.data.success) {
installation.manifest = res.data.manifest
return control.install({
href: installation.href,
manifest: installation.manifest,
launch: installation.launch
})
.progressed(function(result) {
installation.update(50 + result.progress / 2, result.lastData)
})
}
else {
throw new Error('Unable to retrieve manifest')
}
})
}
})
.then(function() {
installation.okay('installed')
})
.catch(function(err) {
installation.fail(err.code || err.message)
})
}
}

return installService
}