appGyver Steroids SQLite Cordova Plugin - sqlite

I'm using steroids by appgyver (update to latest version which includes supersonic as well) to develop my app.
I'm confused about the SQLite plugin. First they supported and included it, then they remove it, then they say that it will not work unless you configure the custom build (and there is no much documentation about that)...
I have a very simple application: textarea and button. When you click the button you insert intto the database the value.
According to the docs https://github.com/brodysoft/Cordova-SQLitePlugin
I'm using var db = window.sqlitePlugin.openDatabase({name : "mydb"});
to open the database. I have the scanner app updated on both android and ios. The result is that in IOS works fine while in Android I get this error: "Cannot read property 'openDatabase' of undefined".
My question is: for IOS the app will stop working once deployed on the appstore?
Why it's working with IOS Scanner? Is it supposed to work? I understood they removed SQLIte support. I don't understand. Then, cause in IOS works, why in Android is not working?
Moreover, how to include SQLite plugin in a steroid project? Anyone was suffesfuul with that? I love appgyver, they did a wonderful job with steroids and supersonic, but... for this SQLite plugin and related support (even an example would do) I'm a bit concerned regarding my decision to go with steroids and not with xamarin for example.
Thank you guys.

AppGyver dev here! You need to include the SQLite plugin as a custom plugin to your app using our Build Service, and then build a stand-alone app: http://docs.appgyver.com/tooling/build-service/
The SQLite plugin is included in the iOS App Store Scanner for preview purposes, so that's the reason it's working on iOS and not on Android. This is actually something we're removing soon, so sorry for the confusion.

Related

How to include Android.Support.v4 in Xamarin Forms (iOS)?

I am using Visual Studio For Mac. My Xamarin Forms project is quite large and contains many content pages. Some of them will be only used in android project and some of them only used in iOS project. There is no problem when I compile the project into android. However, when I want to compile the project into iOS, it seems like did not accept anything related to android. Please refer to the screenshot. There is no way I can include the android specialised reference and compile into iOS project. So, any idea to deal with this? Maybe there is a way to force build the iOS project no matter what? The error from the screenshot is from the page that will be only used in android. So what I can do for now is delete the page when I want to compile as iOS and recreate the page when I want to used it for android. But there are plenty of them, it is too heavy for me to do this every time. Please help.
You can't call platform specific APIs at the .NET standard libraries that are used to host Xamarin.Forms code by default.
Basically you have those options:
1) using shared project instead of library and using conditional compiling (easier but it is now not available as the option when creating the project)
2) using dependency injection.

How To Setup Google Firebase Dynamic Links in Xamarin Forms - Android Edition

How do you setup google firebase dynamic links, deep linking, in a xamarin forms app?
This is how I setup Firebase Dynamic Links in Android project of my Xamarin Forms App, so most of this will apply directly to android. I will work on finishing and documenting the iOS implementation in the future.
Disclaimer: I'm not an expert, any or all of this could be wrong. It's just what worked for me and my basic understanding. Please let me know if there are any errors and let's improve our collective intelligence of the Xamarin Community
If you don't already know what Dynamic Links are, watch the 2 min video, it's a great overview. https://firebase.google.com/docs/dynamic-links/
The Setup
Setup is broken up into 2 parts.
Part 1 - Configure the Dynamic Links in the Firebase Console (Easy)
Part 2 - Configure your app to be able to receive and process the Deep Links (Not as Easy)
Part 1 - Configure the Dynamic Links in the Firebase Console (Easy)
1- Setup a free firebase account at https://firebase.google.com/
2- Create a project.
3- Create a new dynamic link, the tab is at the bottom of the 'Grow' section.
It will generate a static domain name for you based off of your project name. Ex. 'https://myproject.page.link'
Short Link url is what users will click on to navigate to your appstore or launch your app.
Deep Link url is what actually gets sent into your app for you to work with. Ex 'https://myproject.com/MainPage'
iOS behavior. Currently set mine to open the link in a url browser, as my app is not connected to it yet.
Android behavior Very Important but not as hard as my explanation makes it look.
Here is where you register your app with firebase. The package name should be easy, use the same one as defined in your
apps Android properties. Ex 'com.mycompany.appname'
Adding the signing certs SHA-1 and SHA-256 are required for Dynamic Links, which is what we are doing here.
Microsoft has a great guide on this, better than I can explain. here
Download the google-services.json file - You will need it later. Also, you will need the one that has incorporated the SHA cert details in it.
Ignore the instructions for adding the firebase SDK, we will add these to our project later using Nuget packages.
When this is all done your app should be selectable in a dropdown for the android behavior.
Finally, add any extra tags to your dynamic link url if you want, its optional.
And that's it! Now you should have a working short link. When used on an android device it should already be able to determine if the app is already installed or not, and then either direct the user to the play store or open the app. However, it won't do anything with that deep link url that you set. That brings us to the next part.
Part 2 - Configure your app to be able to receive and process the Deep Links (Not as Easy)
1- Versions, might be important.
2- Nuget Packages - Hopefully this goes smoother for you than it did for me.
3- The Code
3a- Intent Filters
3b- Handling the Deep Link
1- Versions.
I was having a lot of issues trying to get dynamic/deep linking to work. So I went back and updated everything to the newest versions available at the time.
Visual Studio Professional 2017 - 15.7.5
.NET Framework 4.7.03056
Xamarin 4.10.10.2
Xamarin.Android SDK 8.3.3.2
Android SDK Manager - Got the latest. Android 8.1 API 27 and Android 8.0 API 26 (Targeting 8.1 might be required)
Android Properties -
-Application - Compile using Android Version(Target Framework): Android 8.1 Oreo
-Android Manifest: Target Android Version: Use Compile SDK Version(haven't tried targetting 8.1 directly, might work). My min target is still Android 4.4 API 19 Kit Kat
2- Nuget Packages. These are just for the Android project. MyApp.Android
You shouldn't have to add anything into the .NET Standard Project, just make sure the Xamarin.Forms Versions match
Below is what I did
Update:
Xamarin.Forms - updated to 3.0.0.482510
Install:
This is where it immediately got annoying for me. Issues here are what lead me to go back and update my Android API Levels to the most recent, 8.1
Xamarin.Firebase.Dynamic.Links by Xamarin Inc v60.1142.1 is what you want to install.
The other dependencies should automatically install. In my case, they did not.
Dependency MonoAndroid,Version=v8.0 is important here. That should be the SDK API version that your app is set to compile against.
However, the other dependencies like Xamarin.GooglePlayServices.Basement (= 60.1142.1) have nested dependencies of their own that require MonoAndroid,Version=v8.1
So if you run into issues installing the Dynamic Links Package, thats where I would recommend looking first.
For my purposes, the nested dependencies were not automatically getting installed, so I went down through each of them and their lists and did them all manually. Even the ones that said not to do manually. It's only 20 or so, but my guess would be if I had my project SDK's set to 8.1 before all of this that it would have gone smoothly.
The CODE
Intent Filters
These are defined in your AndroidManifest.xml file
What do they do? They listen for instructions while your app starts.
When an app start matches a pre-defined filter(short link), they it stores your intended action or data on the Intent Class. That is where we pull the deep link from.
For us, this is what let's the android app receive and begin to process the deep link url that you set all the way back in Part 1.
The firebase dynamic link docs have a good breakdown and example of what to do. here
The android developer docs have a good example and breakdown of this also. here
NOTE Focus on whats between the activity tags. I've just included the other tags to show general structure, in case you haven't edited these before.
That is about the minimum of what you need.
The highlighted line should match the Short Dynamic Link you setup in the established in the Firebase Console.
I'd recommend using a Wildcard like I did in the path prefix.
That way you can make new Dynamic Links and your app can handle them without having to release new versions.
Handling the Deep Link
At this point if your app is launched by the short link, you should be able to catch the deep link during the android startup process and handle it how you want.
All I will cover here is a basic example of how to get the Deep Link as a string.
I pass mine to the main app project (.NET Standard Library) using a simple dependency service.
You can use it however you want though, there's actions it can take in either the App or the App.Android project.
The important thing is getting the deep link.
The firebase docs have good examples, but written in java or whatever language native android uses. here
I'll be showing mostly the same, just in C# examples
Get The Intent.
What is the intent you want to get? The deep link you are sending into your app Ex. "https://mycoolapp.com/mainpage"
You want to get it in the MainActivity. Below is an extremely simplified example, but it's just about that easy. Now you should be able to do what you want with that link inside of your app.
TIPS
Be careful if you have something that interrupts your startup procedures.
My Application uses a splash screen. Part of that is a line of code that creates a new Intent, overwriting the one sent in from the dynamic link
So I have my DeepLinkHandler fire off before that operation, and store the deep link in a static string.
Once it's in a static string I can use a dependency service from the Main App(.NET Standard Library) to call the GetDynamicLinkString method and return the deep link as a string.
How to Test Using an Emulator and Debugger
I have a simple settings page on my app. I added a field that would print the deep link, if it has one.
Fire off the emulator like normal using the debugger. The deep link field should be empty.
With the emulator still running, minimize the app.
Open a browser and enter in the short link url.
This should re-launch your app, but this time the deep link field has the url that you set on the firebase console.
Hope this is able to save someone some headaches.
-Tim

Prepopulated database in cordova app: too slow and splashscreen shown too late

I'm using cordova 3.4.0 and the sqlite plugin (https://github.com/brodysoft/Cordova-SQLitePlugin) to develop an android app with a prepopulated database. I configured the plugin and the database following this post: http://www.corporatezen.com/2012/11/shipping-prepopulated-database-phonegap/
The problem is that the first time the app is launched, it copies the database from the assets folder to the database folder and on old devices with android 2.3.x it can take more than 10 seconds (I have a 90MB database). During this time the screen is black and users may think the app doesn't work and close it.
I tried to look for a faster way to copy the file, but I couldn't find anything.
I tried also to set a splashscreen, using the splascreen plugin (https://github.com/apache/cordova-plugin-splashscreen/blob/dev/doc/index.md) but it appears only after the black screen phase.
Do you have any suggestion?
Solved with this plugin: https://github.com/an-rahulpandey/cordova-plugin-dbcopy
With this, the java code to copy the db is called by the plugin and it's easier to show to the users a warning message created with HTML & Javascript.
I also agree with Sergio.
"dpcopy" is a simple, but a powerful tool.
https://github.com/an-rahulpandey/cordova-plugin-dbcopy
And I also recommend you to apply "Cordova-sqlite-evcore-extbuild-free."
Currently, I'm designing my apps with Cordova, IONIC in Visual Studio 2015 and I applied those two plugins above for prepopulated DB.
The following Git also will solve your question.
https://github.com/ymochi/prepopulated-DB-for-hybrid-applications

MvvmCross, SQLite, Store App?

I can get MvvmCross working with a Windows 8.0 Store App.
I can get SQLite working with a different Windows 8.0 Store App.
I cannot figure out how to get MvvmCross + SQLite working on a Store app.
I always get this Exception:
Failed to construct and initialize ViewModel for type Flux.Core.ViewModels.TestViewModel from locator MvxDefaultViewModelLocator - check MvxTrace for more information
I've spent the entire day searching with google, hoping to solve this myself. The KittenDb example is about as close as I've come, but there's no Store app example in there. (I got the Kitten example working no problem on Android.)
Is there any working example out there?
Thanks!
SQLite for Windows Store is a C++ component and comes in separate ARM, x86 and x64 binaries.
To install it, you need to add a Visual Studio extension - instructions in http://blogs.msdn.com/b/robertgreen/archive/2012/11/13/using-sqlite-in-windows-store-apps.aspx - and then reference that extension from your UI project.
To then link the correct platform version of the Cirrious.MvvmCross.Plugins.Sqlite.WindowsStore.dll assembly to your UI project, you further need to adapt your .csproj file with a <Choose> block a bit like the one in https://nuget.codeplex.com/discussions/446656
There is an open issue within MvvmCross to make SQLite easier to use from nuget (see https://github.com/MvvmCross/MvvmCross/issues/307) but I don't know if anyone is actively working on addressing this issue currently - currently users seem to be just putting up with challenges of different processor architectures and following the manual steps to adapt their projects.

How to run a PhoneGap app with Sqlite in Ripple?

I have a phongap app with a sqlite plugin that runs in both android and iphone. When I try to run it in Ripple i get several errors depending on the inclusion of the cordova version and device I use. Non of them are working at all. In some comments in stackoverflow i've seen people running sqlite in phonegap under ripple.
I'm using the PG-SQLitePlugin-Android plugin in my project, which it acually only supports Phonegap 2.7.0+.
I've found that i can force Ripple to use 2.7.0 by calling it :
file://localhost/Users/----/----/----/www/index.html?enableripple=cordova-2.7.0
Ripple actually loads great after enabling access to file system through chrome.
When i include cordova-2.7.0.js in my script
The index.html pops me a pop up with the following text :
gap:["Device","getDeviceInfo","Device119187522"]
that i can accept or cancel, then 2 more dialogs appeare, if I accept it gets hanged.
the js console shows that cordova 2.7.0 is really running :
Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only. cordova-2.7.0.js:906
deviceready is not fired
When i include cordova-2.9.0.js in my script
It happens the same as 2.7
Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only. cordova-2.7.0.js:906
but this time I get this other errors
Failed to load resource file://localhost/Users/laullobetpayas/-------/---/------/www/cordova/cordova_plugins.json
Failed to load resource file://localhost/Users/-------/---/------/www/cordova/cordova_plugins.js
deviceready is not fired
When I don't include any cordova.js in my script
SQLitePlugin.js:31
Uncaught ReferenceError: cordova is not defined SQLitePlugin.js:34
Am I using the proper plugin ?
which is the propper version of cordova / device tu run with the plugin and ripple ?
Do i have to include the cordova.js in my project
Hel will be very apreciated, it's for a long time that I'm trying to solve this.
Thank you in advanced.
Phonegap plugins won't work with Ripple because the idea of a Phonegap plugin is that it provides a Javascript interface in order to execute native code. That means, in the case of Android, the Javascript will invoke native Java code and in the case of iOS, the Javascript will invoke native Objective-C.
Ripple is purely Javascript-based, so the Javascript part of the plugin has nothing to interface with.
In the case of the SQLitePlugin, for example, calling SQLitePlugin.close() results in the call:
cordova.exec(null, null, "SQLitePlugin", "close", [this.dbname]);
where SQLitePlugin is the native class name and close is the native function name.
If you want to use the same storage API across Android, iOS and Ripple, maybe consider using lawnchair with appropriate adapters.
As for the issues with Ripple and Phonegap 2.7.0/2.9.0, Ripple has not quite caught up with Phonegap, so you will get these popups and error messages in the console, but that will not stop your Phonegap app (without native plugins) running in Ripple. You can convince yourself of this with a simple test case like:
document.addEventListener("deviceready", function(){
alert("I'm alive");
});
But the answer is, yes, you do need to include cordova.js in order for it to work at all in Ripple.
The Cordova-SQLitePlugin is a drop-in replacement for the HTML5 SQL API, so when running inside Ripple you don't need to call the Cordova layer you can just replace calls to sqlitePlugin.openDatabase() with window.openDatabase(). I've not yet tested this with Ripple but it should work. There are some database size limitations but this is probably all you need for testing.
There several ways to test if your inside Cordova. You could create a shim for the openDatabase() method based on testing for Cordova on app startup.
Since your primary goal is really to do rapid testing of SQLite with Cordova (rather than specifically to use Ripple) I'd like to suggest another new alternative to using Ripple.
I wrote an app call Sencha Touch Live that can be used for rapid development of Cordova / HTML5 apps by allowing you to Live Edit and Debug the HTML/JS/CSS code on your mobile device simply by updating files on your development computer - so you can skip most recompile/redeploy/restart debugger time costs. It has tons of other cool features. I'm using it myself for SQLite app testing instead of Ripple or Weinre
Detailed overview and Step by Step Guides
Installation Guide
It's based on the code from Adobe's PhoneGap Developer App so core code is well tested. It's been extensively adapted and tuned for Sench Touch framework though it should also work for jQuery Mobile or any framework that places HTML5 code under the phonegap/www or cordova/www folder. Just start up the server in you PhoneGap or Cordova project folder.
For testing your SQL and controller logic, I recommend using Geny Motion emulator with a version of Android 4.4.x KitKat. Start up an recent version of Chrome on your desktop and once you get your app working on the emulator or real device open chrome://inspect and now you can use the full Chrome debugger on your remote device app. You can also use a recent version of Safari for OSX/iPhone Simulator testing.
You can watch a demo here (starts at the 5 min. mark). Yes! It needs a more polished video with less echoes but you'll get the idea:
https://www.youtube.com/watch?v=94J4HBB0f7I

Resources