How to update/download the application within app itself - ios

I have developed application in Swift. Application is enterprise application so it will never go live on App Store.
I need to update the application within app if update is available for the application.
Right now I have done with backend and iOS side code. I have created .plist file which contains my uploaded .ipa file url and other things. ref
I have successfully implemented code of how can I download and update the app within app itself.
But the issue is when app start to download it stops at 60% and when I try to retry download it's shows error Unable to Downlaod App.
Is there any way I can implement the same idea ?
Swift code
func getTheData() {
let appversion = NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"] as! String
var query = PFQuery(className:"AppVersion")
query.getObjectInBackgroundWithId("Parse unique key") {
(version: PFObject?, error: NSError?) -> Void in
if error == nil && version != nil {
let oldVersion = version?.valueForKey("version") as! String
println(version?.valueForKey("version"))
if appversion == oldVersion {
println("Same Version")
}
else {
println(version)
println("Different version")
let url = version?.valueForKey("ipaURL") as! String
UIApplication.sharedApplication().openURL(NSURL(string:url)!)
}
} else {
println(error)
}
}
}
ANSWER:
I have found the issue.The issue is with iOS 9.0 and above only. From XCode 7 and above, you have to generate(Not manually) manifest.plist file with organizer only. When you are creating ipa file using export option in organizer you will get two options 1)Bitcode 2)generate manifest for OTA update. You have to crete Manifest.plist file with XCode's organizer only.

Seeing as the app is open, I would recommend showing the user a message to update. The AlertView button action should take the user to the webpage to download the new version.
This is not ideal from what you are trying to achieve, but is a way I have done it in the past and works fine.

The issue is the provision profile when you create Archive that time you need to correct device which is listed into provision profile.
Before few days same issue I face and connected same device along with provision profile UDID container.
So I created R&D over that and solve the same problem.

Related

WatchKit App Cannot Connect to the Internet. Works on Simulator but not on Physical Device

This is my first WatchKit App.
I am working on an app that gets an API call to an iCal file and displays the time remaining in two events.
I am working on Xcode 13.4.1 and created an iOS app with watchOS app using swift and storyboard. I set the target deployment for the iOS app to 15.5, which is the highest version of iOS that my current version of Xcode will let me set. The target deployment for the watchOS app is set to version 6.2 because I have an Apple Watch series 2, and the latest version of watchOS is 6.3. I want the app to at least work for my watch. The code for the iOS app and watch app are pretty much the same. The app works as expected on the watch and phone simulators and on my physical iPhone 8 plus. The problem is that the app does not work on my physical watch.
I created a custom class called API_Manager that handles the API call. I handle my API call as a giant string because I am getting an iCal file and parse it later on in the class. url is defined above. Here is my API call for both the phone and watch app:
public func getData() throws{
//api call
do{
// real url is defined above
let url:String = ""
savedData = try String(contentsOf: URL(string: url)!)
} catch{
print("there was an error with the api call")
throw API_Error.apiCallError
}
// parsing data
}
getData() is called in the init function of the API_Manager class.
init() throws {
// checking internet connection
if (!NetworkMonitor.shared.isConnected){
throw API_Error.noInternet
}
do{
try getData()
} catch{
throw API_Error.apiCallError
}
}
I believe the root of the problem is an Internet connection. I check for an Internet connection before the API call, and if there is no Internet connection, then I throw a custom error. I used this video to create a Network_Monitor class. This is the startMonitoring() function which is called in the applicationDidFinishLaunching() in extensionDelegate of the watch app and application didFinishLaunchingWithOptions in the appDelegate.
public func startMonitoring(){
monitor.start(queue: queue)
monitor.pathUpdateHandler = { [weak self] path in
self?.isConnected = path.status == .satisfied
// getting connection type
self?.getConnectionType(path)
}
}
I created a custom error that is thrown throughout the API_Manager if things don't work as expected. Here is how I created the custom errors:
enum API_Error: Error{
case noInternet
case apiCallError
}
extension API_Error: CustomStringConvertible{
public var description:String {
switch self{
case .noInternet:
return "Error: No internet connection"
case .apiCallError:
return "There was an error with the api call"
}
}
}
I created another enum that is used to display text on a label in the Interface Controller if a specific error is thrown.
enum API_Manager_Status{
case active
case noInternet
case apiCallError
case null // if the api manager is nill
}
Here is how I used the two enums in InterfaceController:
main() is called in the awake() function.
func main(){
do{
apiManager = try API_Manager()
apiManagerStatus = .active
} catch API_Error.noInternet{
apiManagerStatus = .noInternet
} catch API_Error.apiCallError{
apiManagerStatus = .apiCallError
} catch{
apiManagerStatus = .null
}
if (apiManagerStatus == .noInternet){
periodLabel.setText("Error")
timeRemaining.setText("No Internet")
print(API_Error.noInternet)
} else if (apiManagerStatus == .apiCallError){
periodLabel.setText("Error")
timeRemaining.setText("API Call")
print(API_Error.apiCallError)
} else if (apiManagerStatus == .null){
periodLabel.setText("Error")
timeRemaining.setText("Other Error")
print("Cought all errors")
} else{
// main code to display time remaining
}
So I guess my questions are:
Why is my Apple Watch not getting an Internet connection?
How can I fix my app if it worked on the simulators and iPhone, but not watch?
Can the Apple Watch do an API call?
Do I need to configure my app to connect with the iPhone, given that my watchOS verison is 6.2?
Sorry if this is a long question. This is my first time posting a question on Stack Overflow. I would appreciate any help. Let me know if I need to add any more information to help clear things up.
I have tried many potential solutions to fix the problem, but none have worked:
I distributed the app on Test Flight and had my dad download it. He has an Apple Watch Series 4 running on watchOS 9.2, and the app still does not work on his watch.
I have restarted my phone and watch multiple times and even tried to run the app with my phone off, so the watch could connect to wifi.
I tried to install a watchOS 9 beta profile on my watch, knowing it would not work, but I still wanted to see what would happen.
I tried setting the build target to watchOS 8.5, which is the highest my version of Xcode would allow, to see if the problem was watchOS 6.2, and if it would work on my dad's watch.
Lastly, I tried adding privacy messages in the Info.plist for both the phone and the watch app. The messages did not display when I re-downloaded the app, but it still did not fix the issue.
(the messages I used were: "Privacy - Nearby Interaction Usage Description" which does not work on watchOS 6.2, but I still kept in the info.plist, and "Privacy - Bluetooth Always Usage Description")
I know Apple Watches are supposed to use the connected phone for Internet and then wifi if a phone is not connected. My watch shows that my phone is connected, and I have tried it with just wifi. I believe my watch can still get an Internet connection because I can still use Siri and even go to the App Store on my watch, which needs an Internet connection. I would appreciate any help. Let me know if I need to add any more information to help clear things up.

Why am I getting a AXServer error when sharing data via Snapchat SDK?

I am using the example xcode project for sharing media between my app and Snapchat directly. I have successfully authenticated my app by this point (it loads bitmoji + user info and I can print the access token). The code that causes the error is invoked after the UIPicker has selected an image:
from line 38 of MediaPickerViewController.swift
fileprivate func shareImage(image: UIImage) {
let snapPhoto = SCSDKSnapPhoto(image: image)
let snapContent = SCSDKPhotoSnapContent(snapPhoto: snapPhoto)
// Send it over to Snapchat. This produced the error below
snapAPI.startSending(snapContent)
}
Then when you pick an image from the gallery:
2020-03-23 17:49:54.487603-0700 CreativeKitSample[20966:5903027]
[AXRuntimeCommon] AX Lookup problem - errorCode:1100 error:
Permission denied portName:'com.apple.iphone.axserver' PID:20969
This is running on my iPhone, debugging over USB. I'm new to Swift development, and my best guess is that my app is developer certificate signed, perhaps it is sandboxed on iOS 13 from communication with prod apps? Or is the AXServer more of a Core UI thing or Accessibility? This project uses Interface Builder/Storyboards. I tried disabling accessibility checkbox on UI elements. I'm at a loss here, searching for AXServer permission errors has not been useful.
some AX errors:
https://github.com/TimOliver/TOCropViewController/issues/402
https://forums.developer.apple.com/thread/120696 (clue that it may be inter-app permission)
https://bugs.webkit.org/show_bug.cgi?id=203618 (sandbox extension?)
I'm an idiot. When I created my Apple Developer Cert and Provisioning Profile, I had a collision with the package identifier, so I changed it in the provisioning settings but neglected to update the snapchat portal's bundle ID. Leaving the question here for anyone else with the same problem.
They could make their error a bit more descriptive...
I got maybe a solution... I'm dismissing before the current View Controller, then present the SFSafariViewController.
Using following Code does help me out! (Xcode 11.3.1, macOS 10.14.6, iOS 13.3)
DispatchQueue.main.async(execute: {
// code goes here
})
// my solution...
DispatchQueue.main.async {
self.present(safariVC, animated: true, completion: nil)
}

How to know installed application is installed via TestFlight or AppStore?

I want to know about how to check user installed application is installed via Testflight or AppStore. So based on that I want to make some environmental change in whole application.
Is there anyway to find that by coding. Is Apple is providing any API for it?
Any help will be appreciated.
I found little snippet about how to know if application is installed via TestFlight.
Here, appStoreReceiptURL is an instance property, which we can find from main bundle.
func isTestFlight() -> Bool {
guard let appStoreReceiptURL = Bundle.main.appStoreReceiptURL else {
return false
}
return appStoreReceiptURL.lastPathComponent == "sandboxReceipt"
}

Apple Watch screen stays blank telerik

I use Telerik-AppleWatch plugin for cordova.
i followed the instructions and i copied the simplified example from the project.
when i run the project the Built successfully but on the iwatch i see just the name of the app and blank screen.
I didn't receive error on the console.
i use xcode. target is- 8.2
There is not much information on the internet about it
function initAppleWatch() {
applewatch.init(function () {
alert("init");
onAppRequestsUpdate();
onGlanceRequestsUpdate();
});
applewatch.callback.onLoadAppMainRequest = onAppRequestsUpdate;
applewatch.callback.onLoadGlanceRequest = onGlanceRequestsUpdate;
}
can anybody know what can i do?
I work on it all week without success
thanks!:)

SPErrorGizmoInstallNeverFinishedErrorMessage in Watchkit

I am running a watchkit app which uses app groups and I can't seem to get it running at all. Anytime I try and run the app I get an alert which says "SPErrorGizmoInstallNeverFinishedErrorMessage".
The code in my glance controller is relatively short.
let sharedGroupName = NSBundle.mainBundle().objectForInfoDictionaryKey("Shared Group") as! String
var sharedDefaults:NSUserDefaults!
override func willActivate() {
super.willActivate()
sharedDefaults = NSUserDefaults(suiteName: sharedGroupName)
var timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: Selector("update"), userInfo: nil, repeats: true)
}
func update() {
println(sharedDefaults?.valueForKey("timeMessage") as! String)
}
The code in my ViewController.swift is short as well also just setting this share defaults object:
let sharedGroupName = NSBundle.mainBundle().objectForInfoDictionaryKey("Shared Group") as! String
var sharedDefaults:NSUserDefaults!
sharedDefaults?.setObject(timeMessage.text, forKey: "timeMessage")
sharedDefaults?.synchronize()
This error is preventing me from running any watchkit app at all. Not the main app or the glance or notification.
I have one app group which is listed in the info.plist.
I have a custom build setting to the app groups name.
Any help would be greatly appreciated.
I fixed this issue by going to the simulator's watch companion app, unchecking the installation for the watch app, then turning it back on. Nothing else worked.
The only thing that worked for me was to Reset Content and Settings in the simulator. Toggling the watch app off and on in the Apple Watch settings app didn't do it for me.
From reading other Apple Developer forum messages, SPErrorGizmoInstallNeverFinishedErrorMessage seems to occur when the Watch App info.plist has an invalid setting.
I was trying different versions of WKCompanionAppBundleIdentifier and that was my error. When I deleted the copied line, that worked again.
This message started appearing when I added custom keys in the info.plist file.
After much trial and error I was able to fix this by unplugging my external display from my computer. Whether this was the real issue I don't know. All I know is that when I had the external monitor plugged in I got this error and when I unplugged it the error went away. I tested it several times.
For me, it was "Targeted Device Family" settings
For parent app, you could keep it iPhone/iPad (or iPhone, up to you);
For watchkitextension, set it to iPhone;
For watchkitapp, if you want to run in the simulator, set it to iPhone. For actually device, the value seems to be 4 (which you cannot set directly from Xcode yet as of 20150416)
I did nothing but restart Simulator & Clean-build app, then it worked again. :)
If you want to use the group to share the data with IOS app and your apple watch kit using the NSUserdefault, you can follow these steps:
1. Add the group app id in capabilities part of IOS targets app and target watch kit
2. when you want to save the data to NSUSerDefault:
var groupData = NSUserDefaults(suiteName: "group.demoShareData")
// note that suiteName is group app id
// var str = "demotest"
groupData?.setObject(newYearLabel.text, forKey: "timeRemaining")
groupData?.synchronize()
3. when you want to take the data from NSuserDefault:
var groupData = NSUserDefaults(suiteName: "group.demoShareData")
groupData?.synchronize()
if groupData?.objectForKey("timeRemaining") != nil {
var str = groupData?.objectForKey("timeRemaining") as String
println("str \(str)")
self.myLabel.setText(str)
} else {
println("error")
}
Hope this help :)
I found a solution in Xcode 8.3. Make sure that the build setting "Targeted Device Family" is set to iPhone in the WatchKit extension.
I Deleted the App from the simulator, and reinstalled. Seemed to work.
I tried a couple of the other option.
CMD SHIFT K - clean
CMD RUN - run
the error dissapears!

Resources