UUID Changes after updating from ionic 1 to ionic 2


#1

Hi, I would like to update an ionic v1 app with a new ionic v2 app version. I have some trouble with locally stored data on ios devices.
I’m using pouchDB in ionic 1 and want to migrate to ionic storage in v2. But after some testing i noticed that the uuid changes and therefore the path of my pouchDB database is different. Can someone help ?


#2

What defines this UUID? Is it a thing of puchDB?
How is it stored or persisted? Can you somehow influence it?


#3

Generally the uuid is generated if a user installs the App (automatically, not by me).
I’ve read some post and they mostly say that the uuid stays persistent if the app gets updated.
Uuid should only change if the app is deleted and reinstall (or reinstall with itunes/icloud backup).
But in my case the uuid seems to change if I update my ionic v1 app with my ionic v2 version.

I found the file path to my database file and it looks like the path includes the uuid.
Therefore the paths are different.

If I install the ionic v1 app, create some data and then install the v2 app, all data seems to be gone. But if I increase the version number of the v1 app and install it as an update for the v2 app, my datas appear again.


#4

Again:
Is that UUID generated by pouchDB, the app or the system?

The new Ionic v2 app is not an update to your app, but a full replacement - which makes it more difficult to keep the same data etc. You are also probably using all different library versions, maybe there is some difference in how the UUID is calculated?

Is the old database still there after the update and just not accessible?
Can you access this UUID in the Ionic v1 code and maybe save it somewhere else so the v2 app can use it?


#5

I don’t know how it gets generated. I think it is something apple did automatically when a user installs an app.
It dosen’t come from pouchDB, cause the uuid is necessary for the file path on iOS
Edit: You have an uuid in every iOS app, not only when app uses pouchDB

/var/mobile/Applications//

on Android the apps storage path looks like /data/data//
therefore I only got this problem on iOS.

“Is the old database still there after the update and just not accessible?
Can you access this UUID in the Ionic v1 code and maybe save it somewhere else so the v2 app can use it?”

I can’t find the old db with the v2 App because of apples sandboxing system. As I mentioned above the v2 app has a different path as the v1 app, therefore I can’t access the path to the old database file.


#6

Ok, so this has nothing to do with pouchDB, but “just” that an app update on iOS makes the OS put the app data into a different internal directory, wiping out all old data. Correct?


#7

Not exactly.
It only appears if the update is another ionic version. If I update the ionic v1 app with the ionic v1 app (higher version number), all data stay in database.

And I don’t think they get wiped out if I update the v1 with the v2 app.
If I update the v1 with v2 app and then update the v2 app again with the v1 app (higher version number) then I get all datas back.


#8

Which would mean that the Ionic v2 app for some reason gets assigned another UUID by iOS on installation… unfortunately I don’t know anything about this process. Could you google something and find some documentation on it?

What happens if you deinstall the v1 app an install it again? Same UUID?

Can you post the ionic info output of both the v1 and the v2 app?


#9

Blockquote
Which would mean that the Ionic v2 app for some reason gets assigned another UUID by iOS on installation… unfortunately I don’t know anything about this process. Could you google something and find some documentation on it?

I already did, but I can’t find a solution in the last 2 months.

Blockquote
What happens if you deinstall the v1 app an install it again? Same UUID?

No, I got a new one, it only stays the same if I update the app with the same ionic version.

Blockquote
Can you post the ionic info output of both the v1 and the v2 app?

IONIC V1:

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0
Gulp CLI              : CLI version 3.9.1 Local version 3.9.1

local packages:

Cordova Platforms : android 6.4.0 ios 4.4.0
Ionic Framework   : ionic1 1.3.1

System:

ios-deploy : 1.9.2
Node       : v9.11.1
npm        : 6.1.0
OS         : macOS High Sierra
Xcode      : Xcode 9.4.1 Build version 9F2000

Environment Variables:

ANDROID_HOME : not set

Misc:

backend : pro

IONIC V2:

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.1.9
Cordova Platforms  : android 7.1.0 ios 4.5.4
Ionic Framework    : ionic-angular 3.9.2

System:

ios-deploy : 1.9.2
Node       : v9.11.1
npm        : 6.1.0
OS         : macOS High Sierra
Xcode      : Xcode 9.4.1 Build version 9F2000

Environment Variables:

ANDROID_HOME : not set

Misc:

backend : pro

#10

Thanks for the info.

Ionic doesn’t really have to do anything with the “native app” part - it is just put inside a native container that is built by Cordova. So our task is now to understand what triggers this difference in UUID and causes all these issues…

Best would be if you could replicate the behaviour with the same app somehow.

What happens if you update the v1 app to cordova-ios 4.5.4 and install that version as an update?
Does it also disconnect from the data (= change the UUID)?

Have you tried building a v2 app with the same cordova-ios version as your v1 app, 4.4.0?


#11

Blockquote
duplicate symbol OBJC_CLASS$_CDVLogger in:
/Users/philippkimmlinger/Library/Developer/Xcode/DerivedData/Bito-hdauvtwnvsfwqfgrmnicoexxdkrg/Build/Intermediates.noindex/Bito.build/Debug-iphoneos/Bito.build/Objects-normal/arm64/CDVLogger.o
/Users/philippkimmlinger/Library/Developer/Xcode/DerivedData/Bito-hdauvtwnvsfwqfgrmnicoexxdkrg/Build/Products/Debug-iphoneos/libCordova.a(CDVLogger.o)
duplicate symbol OBJC_METACLASS$_CDVLogger in:
/Users/philippkimmlinger/Library/Developer/Xcode/DerivedData/Bito-hdauvtwnvsfwqfgrmnicoexxdkrg/Build/Intermediates.noindex/Bito.build/Debug-iphoneos/Bito.build/Objects-normal/arm64/CDVLogger.o
/Users/philippkimmlinger/Library/Developer/Xcode/DerivedData/Bito-hdauvtwnvsfwqfgrmnicoexxdkrg/Build/Products/Debug-iphoneos/libCordova.a(CDVLogger.o)
ld: 2 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

that appears when I update Cordova-ios from 4.4.0 to 4.5.4 and then try to update the v1 app.

I’ve installed the v1 app with 4.4.0 and then remove and add the iOS platform again. That gives me a new uuid.

I donwgraded the v2 app to iOS 4.4.0. Same issue.

v1 app
file:///private/var/mobile/Containers/Data/Application/F1191C07-9EA1-4AEB-8BA6-6020BF61F1F5/Library

v2 app
file:///private/var/mobile/Containers/Data/Application/CB9E7EF4-6EE0-4CDF-BCE5-9593EAFFDCA9/Library


#12

That points to an issue with some plugin that is now integrated… probably this: https://stackoverflow.com/a/46344099/252627

Same error message as above or also new UUID?


#13

Thanks, now I can run the v1 app with cordova-ios 4.5.4

Same error message as above or also new UUID?

new UUID, sorry that was not clear.

Now I started my v1 app with the new iOS platform I’ve got a new UUID
file:///private/var/mobile/Containers/Data/Application/17F26FF5-8043-4FC2-AFB8-FB48B6A512F6/Library/
But I can still see my data.


#14

Huh!? Explain please.


#15

I’ve stored some data in ionic v1 app with cordova-ios 4.4.0.
then:

  • remove platform
  • add platform (4.5.4)
  • build project
  • start project

the database gets loaded and my datas are in.

On app start I load the db and show all datas in a list view.


#16

That’s good.

But the UUID still changed you say? How is this possible?
Did iOS migrate the data from the old data directory to the new one?

Now the next step would be to find out how you can get the same behaviour for the Ionic v2 app…


#17

I don’t know, it’s very hard to find the right path in iOS because of the sandbox mechanism.

I tried some stuff, even with local storage but I can’t get the datas in ionic 2 app.


#18

The main thing is to understand why the new app is recognized as a new or different one. Only if this does not happen, the data will be available by both I assume.

There is a Slack for Cordova where you could ask maybe at slack.cordova.io.