Sharing data between apps

Hi,

What is the best way of sharing data between a firemonkey windows application and a firemonkey mobile app?

Thanks,

Ken

Hi,


I'm not sure I fully understand your question.
Can you please explain which component(s) from the TMS Cloud Pack for FireMonkey you are using and exactly what data you would like to share between the windows and the mobile app?

I am trying to decide which component is best to use. I need to obtain a list of items that are in a SQLite table.

This depends on which API service you would like to use or are using. Can you please further explain what you would like to use the TMS Cloud components for?

 I have similar question. I use interbase Lite version on my mobile app and MS access on my desktop. Then I would like to synchronize them. I know Cloud pack doesn't support directly on database table synchronization. The way in my mind is to upload my mobile database to cloud, then have my desktop application to grap it, then do the syn. I have tried google drive, it seems that google registration is quite different from what is in the TMS guide, I got lost and gave up. I also tried dropbox, it didn't work for me. I am wondering if you have some suggestion on data synchronization between apps.
Thanks!

As services change their signup all the time, we have put information online about registration process rather than keeping updating doc that gets outdated.
The latest info on registration for a cloud storage service can be found here:

http://www.tmssoftware.com/site/cloudkey.asp 

it seems that the signup pages are changed again from Google drive and dropbox. The web pages are quite different from the latest TMS help document. At present, I got stuck at CallBackURL and Callback port. They need to be the same as what I got at my service/app registration time. I just couldn't find out where to find out these information. The TMS help online documents out-dated again. Is it a way to create a simple account at google and dropbox and show us everything on the screen. Where those callbackURL and CallbackPort locate?
Thanks!
Gene.

Hi,


1) Google 
Please follow these instructions to find the credentials for Google Apps:
- Go to: https://console.developers.google.com and select your App.
- Select "Enable APIs and get credentials like keys" on the dashboard in the "Explore other services" topic.
- Select "Credentials" in the left side pane
- Select your web client from the "OAuth 2.0 client IDs" list
- The API Key, Secret, CallBackURL and CallBackPort are displayed on this page

2) DropBox
I haven't noticed any significant changes on the DropBox developers page.
- Go to: https://www.dropbox.com/developers/apps and select your app from the list
- The API Key, Secret, CallBackURL and CallBackPort are displayed on this page

The page with registration instructions (http://www.tmssoftware.com/site/cloudkey.asp ) will be updated as soon as possible.

Hi, Bart,

Thanks for posting those useful help information!
I followed these instructions and successfully create Google/Dropbox API Key,.... But I still have a question about the CallBackURL.
What are CallBackURL and CallBackPort Exactl? I can only see they are empty when I am in the pages that have API Key, Secret... The CallBaclURL is empty. I am a bit confused if I should put in the default http://127.0.0.1:8888, or www.dropbox.com for dropbox and www.google.com for google drive.

It seems that I can get a google login window when I set googledrive component:
TMSFMXCloudGDrive1->App->CallBackURL = "http://www.google.com";
  TMSFMXCloudGDrive1->App->Key = "";
  TMSFMXCloudGDrive1->App->Secret = "
";
  TMSFMXCloudGDrive1->DoAuth();

I put in my user name and password in to that sign in form, but it doesn't let me in. I am wondering if there is somewhere I should check to give authorization or grant access to that user. Is there more information about this?

I am making progress, it seems that I am almost there to get my app connected to the cloud. Thanks a lot for your help!

Gene.

You can use the default CallBackURL (http://127.0.0.1:8888/) and CallBackPort (8888) value. Please note that if you are using multiple services in the same application it's recommended to use different port numbers for each service.

Also make sure the CallBackURL that is configured on the DropBox/Google developers page is identical to the value assigned for the control.

Example:
TMSFMXCloudGDrive1.App.CallBackURL := 'http://127.0.0.1:8889/';
TMSFMXCloudGdrive1.App.CallBackPort := '8889';

TMSFMXDropBox1.App.CallBackURL := 'http://127.0.0.1:8888/';
TMSFMXDropBox1.App.CallBackPort := '8888';

For a full working example, please have a look at the "StorageDemo" application included with the product download.

After signing in for the first time (during the authentication process) a confirmation text and button will be displayed to give authorization to the App to access the user's data on the service.

Hi, Bart,

That Help! I can sign in now. Then I see a form asking if I allow to access my files!

What I am doing is to copy a file from my android app and paste to google drive. Everything needs to be done without that signing in form, Is it possible to store this user name and password somewhere to sign in?

What will be the next step for me? Should I create an instance of TTMSFMXCloudItems and access the files and folders?

Unfortunately, I have only c++ Builder 10 Seattle version. It doesn't include Delphi. So I can't open the sample project to learn what is in there. Another question is if you have sample projects for C++ Builder? I have to go through the document to learn.

Thanks!
Gene.

To do further access, you'd just persist the access tokens and the next time the app is started, you load the persisted access tokens and can continue to work without requiring a new login. See SaveTokens / LoadTokens functionality.

If all you want to do is upload files from Android, you can use the StorageComponent.Upload(filename) method.

SaveTokens / LoadTokens are methods of TTMSFMXCloudStorage. The sample codes in the manual is for delphi, I have trouble to get it to work. The trouble line is:
if (Sender is TTMSFMXCloudStorage)
then begin cs := Sender as TTMSFMXCloudStorage;
cs.SaveTokens;
 end;

I had it converted to this:
TTMSFMXCloudStorage* Ptr;
  if (Sender->ClassType() == TTMSFMXCloudStorage) {
    Ptr=(TTMSFMXCloudStorage*) Sender;
    Ptr->SaveTokens();
  };
That doesn't work. The error message says "E2108 Improper use of typedef 'TTMSFMXCloudStorage'". I just don't know how to fix that.

Another thing here is what StorageComponent.Upload(filename)  is? Is StorageComponent a part of TMSCloud component? I couldn't find it. I searched the manual and found nothing. Can you give more info on that?
Thanks!

1)
Try:
if (typeid(Sender) == typeid(TTMSFMXCloudStorage))

2)
With StorageComponent I meant the abstract name for the cloud storage class you were using, i.e. can be one of TTMSFMXCloudOneDrive,TTMSFMXCloudDropBox, TTMSFMXCloudGDrive etc..

Hi, that works! Now I can copy data file to my google drive. That is great!

Is it a way yo get rid of that google form saying "allow offline access"? Or can I just use a default value for it?

It seems that this doesn't work:
  if (typeid(Sender) == typeid(TTMSFMXCloudGDrive))

I have a TTMSFMXCloudGDrive on my form. I need to check if the sender from TMSFMXCloudGDrive1ReceivedAccessToken event is the TTMSFMXCloudGDrive type. Can I use __Classid()?

On windows, everything works ok. But on android, The authen windows doesn't have the "Have offline access" "Allow" and "Deny" clickable. Has any one else had that problem? I am on C++ Builder 10 Seattle/ windows 7 64bit.
Thanks!

1)

If you just have TTMSFMXCloudGDrive on the form, you can directly access the component TTMSFMXCloudGDrive and do not need to cast Sender to TTMSFMXCloudGDrive.
2)
If you save access tokens (SaveTokens) and the 2nd time use LoadTokens, you can reuse the tokens and no new authentication / authorization is necessary.
3) Isn't there any scrolling possible? 

it is weird, I re-compiled the project and it worked on android this morning.
Anyway, thanks a lot to get me through!

is it a way to check if my upload is successful?