xamarin.forms read app version from app store / google store - app-store

I need to know when i start running my app if a new version exists in Google Play Store / ios app store.
I want to do it by comparing my running app version to the one in the store.
How do i read the app version from the store in run time ?

string url = "http://itunes.apple.com/lookup?bundleId=YourBundelID";
using (var webClient = new System.Net.WebClient())
{
string jsonString = webClient.DownloadString(string.Format(url));
var lookup = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonString);
if (lookup != null
&& lookup.Count >= 1
&& lookup["resultCount"] != null
&& Convert.ToInt32(lookup["resultCount"].ToString()) > 0)
{
var results = JsonConvert.DeserializeObject<List<object>>(lookup[#"results"].ToString());
if (results != null && results.Count > 0)
{
var values = JsonConvert.DeserializeObject<Dictionary<string, object>>(results[0].ToString());
appStoreAppVersion = values.ContainsKey("version") ? values["version"].ToString() : string.Empty;
}
}
}
return appStoreAppVersion;

If there's no easy way to achieve this, build your own easy way ;-)
For example: with every upload to the app store you upload the current version info to an online resource you can access from your app. All you need is a webserver where you can either run your own API or just upload a file containing the version info.
Maybe not a solution you awaited, but it's definitely going to work.

There is no (easy) way to do that. The best way to do it would be to access the app details through some API but I don't think they make that (publicly) available. So the other way would probably to scrape the according sites, but I'm pretty sure they will be unhappy with that method and maybe their license even forbids it.
Also, mostly that kind of solutions is due to poor design. The user has to be able to use the old version for the length of days, although you should strive for fast adoption of your new version.
But just keep in mind while designing your backend etc. that you have to be backwards compatible.
Lastly, as a user I really hate those kind of messages. Depending on what kind of app it is I just want to use it then, not be forced to update, so go out, update, and try to do the thing I opened it for in the first place.

Related

PWA creates IndexedDB database, but does not create any object stores

I have a Vue PWA and it stopped creating my IndexDB object stores on first load or upgrade. Here is my code, I am using the latest version of IDB (https://github.com/jakearchibald/idb):
await openDB('dbname', 1, {
upgrade(db, oldVersion, newVersion, transaction) {
switch (newVersion) {
case 0:
// a placeholder case so that the switch block will
// execute when the database is first created
// (oldVersion is 0)
// falls through
case 1:
db.createObjectStore('change_log', {keyPath: 'id'});
db.createObjectStore('person', {keyPath: 'id'})
.createIndex('username', 'username');
break;
}
}
});
I have tried multiple browsers and incognito tabs, etc. and the same thing always happens. The database is created, but no object stores are created. I use developer tools to clear all the data in the PWA and refresh but the same thing happens.
If I increment the version number, the version of my database gets updated in the browser, but the object stores still do not get added.
The upgrade() function does not get called.
I had this happen to me earlier in my development, and I fixed it, but I can't remember how. I feel like it may not actually be a coding issue...
OK, I found the problem. I added a logging mechanism to my App and there was code running BEFORE my upgrade code that was opening the database to create a log entry. Therefore, it was creating the database (with no object stores) before my upgrade method was being called. I changed my open database code to always include the upgrade method to solve my problems.

IOCreatePlugInInterfaceForService returns mysterious error

I am trying to use some old IOKit functionality in a new Swift 4.0 Mac app (not iOS). I have created a bridging header to use an existing Objective C third party framework, DDHidLib, and I am current working in Xcode 9.
The code that attempts to create a plug in interface for a usb gamepad falls over on IOCreatePlugInInterfaceForService, returning a non-zero error.
The truly bizarre thing is I have an older app created in a previous version of Xcode that uses the same framework and works correctly after opening in the new Xcode 9. This previous project is still Swift using a bridging header for the same Obj-C framework. I have checked the build settings and tried to make everything match, but I get the same result; the old app works but any new apps do not.
Is there a way to either: find out the exact differences in build settings/compilers to see what the elusive difference may be, OR to step into the IOCreatePlugInInterfaceForService IOKit method to see what may be causing the error to be returned in one project but not another?
EDIT: Here is the method that is failing:
- (BOOL) createDeviceInterfaceWithError: (NSError **) error_; {
io_name_t className;
IOCFPlugInInterface ** plugInInterface = NULL;
SInt32 score = 0;
NSError * error = nil;
BOOL result = NO;
mDeviceInterface = NULL;
NSXReturnError(IOObjectGetClass(mHidDevice, className));
if (error)
goto done;
NSXReturnError(IOCreatePlugInInterfaceForService(mHidDevice, kIOHIDDeviceUserClientTypeID,kIOCFPlugInInterfaceID,&plugInInterface,&score));
if (error)
goto done;
//Call a method of the intermediate plug-in to create the device interface
NSXReturnError((*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (LPVOID) &mDeviceInterface));
if (error)
goto done;
result = YES;
done:
if (plugInInterface != NULL)
{
(*plugInInterface)->Release(plugInInterface);
}
if (error_)
*error_ = error;
return result;
}
In the old version that works, IOCreatePlugInInterfaceForService always returns a value of 0. In all the versions that don't work, the return value appears to always be -536870210. The mHidDevice in this function is the io_object_t handle for the device.
EDIT2: Here is the IORegistryExplorer page for the device
Finally managed to resolve this after weeks of head scratching. The new Xcode 9 uses app sandboxing to basically prevent access to USB, bluetooth, camera and microphone etc. by default in a new app. Once I switched this off it reverted to it's expected behaviour.
Glad it was such a simple answer in the end but disappointed Xcode does not provide more descriptive error messages or responses to let a user know they are essentially preventing themselves from accessing the parts of the system they need.
Looks like kIOReturnNoResources is returned if the loop at the end of IOCreatePlugInInterfaceForService completes with haveOne == false for whatever reason. Perhaps Start() is returning false because another process or driver already has exclusive access? I'd check what clients the device has in IORegistryExplorer.
This error also happens when an application is trying to access the camera or bluetooth on MacOS 10.14 and higher. Permission shall be granted either explicitly by user (pop-up window), or through the Security & Privacy. The application should check for permission as shown here.

fire base custom search is stuck

I am doing firebase programming with iOS.
I could do normal searching with code like below
ref.child("Users").queryOrderedByChild("name").queryStartingAtValue(text).observeEventType(.Value, withBlock: { snapshot in
for u in snapshot.children{
print(user.name)
}
})
but i am confused, as i want to find people near me. every record has lat long values, where in the server i would put code to evaluate distance between my current location and friends location and filter them ? I dont want to loop through all items in above for block (Client side)
Also, can i write server code to make services hosted in firebase ? what is the recommended way to get data from big server like redshift ?
Is firebase really drag-drop development ? i did not find anything of that sort in firebase documentation ! firbase-ui is open source, but it gives obj c code and no drag and drop ! request answer please

Preloaded Core Data Storage in Swift 2.0

I am currently making an application in Swift. I was looking into Core Data to store the little bit of data I actually need to store. I want three (permanent number) of these objects stored within the phone at all times.
class Location {
var name = ""
var type = ""
var address = ""
var distance = ""
init(name:String, type:String, address:String, distance:String) {
self.name = name
self.type = type
self.address = address
self.distance = distance
}
}
These are locations of a sort that users can save within the app. Then they can click a labeled button that will load the text fields with the stored data. The user can update them from time to time if they need to. The issue is not how to save within Core Data or fetch it. The question is, how can I have these Entities/Attributes already stored into the app before anyone even runs / downloads it? I figured I could just create these saved locations at start and flag it whether or not this is the first run to eliminate the duplications. But shouldn't there just be a way to build the objects into the program from the start and just manage them from then on? Or is there an entirely different method I am over looking?
I have never used Core Data but it seemed like the way to go from the tutorial book I am reading. It, along with online resources, just state how to build and maintain Code Data from scratch. I could not find how to build a library in and manage it instead.

Can I use this.userId in Meteor.onConnection()?

I am building a mobile application where my users can connect using accounts-facebook.
What I would like to do is refreshing their list of friends that use the app when they are logging in (is this a good way to keep this list up to date ?) or when they are connecting
I built something like this :
Meteor.startup(function(){
myFunctionToRefreshFriendLists()
});
Meteor.onConnection(function(conn) {
if (this.userId) {
myFunctionToRefreshFrindLists();
}
}
But this returns me "undefined", even when the user is connected. I know there is a problem using "this.userId" (this here does not seem relevant to me) but I do not know what to do ?
Any help appreciated, thank you !
Don't use Meteor.onConnection, as it will run every time a user starts a new connection. This can happen frequently depending on the stability of their connection; instead use Accounts.onLogin:
Accounts.onLogin(function(user){
console.log(user.user._id)
});
http://docs.meteor.com/#/full/accounts_onlogin