Database and DB provider for hybrid mobile app - database

I am new to hybrid mobile app development. I am coming from web based development background so bit perplexed.
I zeroed down on Apache/Cordova for build/packaging my hybrid mobile app. This app would be hosted on all 3 major stores. After my initial research, I got a good flavor of UI pieces/frameworks e.g. Angular, Bootstrap, etc. One thing where I got so confused is back-end storage, services and provider. In other words,
What storage services do i need for storing and pulling data (not offline app data)?
Based on storage service how do I decide on provider. Any guidance?
Best way for making calls for all my CRUD operations?
Do I need any kind of server side operations or client side JS would suffice?
Thanks for your help.

You can use Azure Mobile service to store and pull data, each mobile service comes with database. You can try out the trial version to see whether it meets your requirement.
Follow the below steps to add Azure mobile service to your project through Visual Studio:
1.) Right click on project node and select Add --> Connected Services.
2.) Sign-in with your Azure account. Click on Create Service to create new mobile service.
3.) Select the newly created mobile service and click Ok.
4.) It will add service.js, which contains Azure mobile service object.
5.) You can use Azure mobile service object to perform CRUD operations like
var CordovaAppClient
document.addEventListener("deviceready", function () {
CordovaAppClient = new WindowsAzure.MobileServiceClient(
"https://Dummyapp.azure-mobile.net/",
"IsBLy-----ScCqDMuCCZqVlF------");
});
function ReadData()
{
var table = CordovaAppClient.getTable("Item");
var query = table.where({ complete: true });
query.read().then(function(items)
{
listItems = $.map(items, function (item) {
alert(item.text);
});
});
}
function InsertData()
{
var table = CordovaAppClient.getTable("Item");
var inputTest = $('#txtData').val();
table.insert({ text: inputTest, complete: false })
.then(addmessage);
}

Related

In Back4App project, Can multiple apps (different platforms) can access same database and authentication?

I wanted to use back4app as my backend to my mobile apps & web app/site. My question is can I access same db and authentication in single project (shared plan). If yes show me some reference to get. Thank you. (Try to understand my English).
Yes, you can use the same database for your mobile apps and website, you only need to use the same app credentials in your initialization code.
Let me better explain it:
For Android apps, you must use:
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId("APP-ID-HERE")
// if defined
.clientKey("CLIENT-KEY-HERE")
.server("https://parseapi.back4app.com")
.build()
);
For iOS (swift):
let configuration = ParseClientConfiguration {
$0.applicationId = "PASTE_YOUR_APPLICATION_ID_HERE"
$0.clientKey = "PASTE_YOUR_CLIENT_ID_HERE"
$0.server = "https://parseapi.back4app.com"
}
Parse.initialize(with: configuration)
For iOS (obj-C):
[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
configuration.applicationId = #"PASTE_YOUR_APPLICATION_ID_HERE";
configuration.clientKey = #"PASTE_YOUR_CLIENT_ID_HERE";
configuration.server = #"https://parseapi.back4app.com/";
}]];
And for the website (JS):
Parse.initialize("YOUR_APP_ID", "YOUR_JS_KEY"); //PASTE HERE YOUR Back4App APPLICATION ID AND YOUR JavaScript KEY
Parse.serverURL = "https://parseapi.back4app.com/";
If you use the credentials (App ID, Client Key / Javascript Key) of the same app, you'll connect all your "different" projects to the same database.
In addition, you can get these credentials following this guide: https://help.back4app.com/hc/en-us/articles/115000754772-Where-are-my-Keys-and-ID-

How to connect to SQL Server with Flutter?

I have to use SQL Server with Flutter and I don't have another database option because my client has it. I was looking for packages but I only found a package that doesn't run on mobile. Is there any option to do that without web services or api?
The first thing that you need to consider is that there is no immediate and extremely effective solution and you have to decide what frameworks and tools to be used. And as mentioned in the comment that the market for this scenario is very small. But there are some ways that you can handle this.
Remote storage sample solution:
Here is a basic example of how you should implement this. It was also cited in this SO post:
Client application
The client application can be any application the user typically uses.
Some examples:
Mobile app (written in native, Dart, Xamarin, ...)
Desktop app (Electron, WPF, ...)
Website app (Angular, React, Vue, ...)
API
The API is there to retrieve data, and change data. But It will also
handle authentication, authorization, logging, doing business logic
Database
Your API will then execute queries, inserts, updates, deletes, execute
stored procedures on the Database of your choice. In your example SQL
Server.
There are many possibilities on how to set this up, depending on your
skills, knowledge of frameworks, how you want to deploy things.
How you want to deploy this will limit your choices as well. For your
API:
Serverless API (Via Azure Functions, AWS Lambda)
Cloud Website (Azure Web Apps)
Website hosted on premise
Docker container
In real life scenarios this often gets more complex with Firewalls,
Application Gateways, Virtual networks, clusters.
You can install a SQLServerSocket on your server:
https://github.com/nippur72/SqlServerSocket
Install and execute SqlServerSocket.exe in the background on the server machine where SQL Server is installed.
Also, you need a client:
https://github.com/nippur72/SqlServerSocket/tree/master/DartClient
And you can try some connections and queries directly to your DDBB:
// creates a connection
var conn = new
SqlConnection("SERVER=localhost;Database=mydb;Trusted_connection=yes");
// open connection
await conn.open();
// runs a query returning a single value
var howmany = await conn.queryValue("SELECT COUNT(*) FROM Customers");
// runs a query returning a single row
var myFirstCustomer = await conn.querySingle("SELECT name,age FROM Custormers");
print(myFirstCustomer["name"]);
// runs a query returning all rows
var customers = await conn.query("SELECT TOP 10 name,age FROM Custormers");
for(var customer in customers)
{
print(customer["name"]);
}
// execute a command, returning the number of rows affected
var n = await conn.execute("UPDATE Customers SET age=0");
print("zeroed $n customers");
// disconnect
await conn.close();

IdentityServer4 QuickStart Register Issue

I have ASP.NET Core application with IdentityServer4 using ASP.NET Core Identity (based on excellent quickstart).
http://docs.identityserver.io/en/release/quickstarts/6_aspnet_identity.html
In the walkthrough blog they talk about navigating to localhost:5000/Account/Register to create a new user in the Identity db.
When i navigate to that url i get a white page. Furthermore I don't have a Register.cshmtl page or a Register route or anything with the term Register in it.
Did i get the wrong branch? because i am on the release and using core 2.0
I'm new at this and apologize if i'm missing something obvious.
I have run the dotnet ef command but can't see a db anywhere I look - like in sql express or LocalDb.
I am running the Identity server project out of vs17 on port 5000
If i run the MvcClient project I see the home page with the Secure link. If i click that i am directed to the IS4 instance but alice nor bob login will work. (invalid us/pw).
And i can see in the logs that alice and bob users are not being created in-memory
You probably got this by now, but it might interest someone else.
The Quickstart UI repository is not a direct implementation of the tutorials in the IdentityServer4 docs. If you follow the docs, you will first create a new ASP.NET Core MVC application with Individual User Accounts authentication, and that template will create the registration page.
I think your problem is about routing. With scaffolding Identity and specifying routing Your problem will be resolved.
To maintain full control of the Identity UI, run the Identity
scaffolder and select Override all files.
replace
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
with
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
.AddRazorPagesOptions(options =>
{
options.AllowAreas = true;
options.Conventions.AuthorizeAreaFolder("Identity", "/Account/Manage");
options.Conventions.AuthorizeAreaPage("Identity", "/Account/Logout");
});
services.ConfigureApplicationCookie(options =>
{
options.LoginPath = $"/Identity/Account/Login";
options.LogoutPath = $"/Identity/Account/Logout";
options.AccessDeniedPath = $"/Identity/Account/AccessDenied";
});
// using Microsoft.AspNetCore.Identity.UI.Services;
services.AddSingleton<IEmailSender, EmailSender>();
Now you can access to Register account page:
http://localhost:5000/Identity/Account/Register
You also can also change default route like what you want (localhost:5000/Account/Register) for this purpose check this post

Azure MobileServices Live/UAT/Dev environments

I have an azure mobile service that will go live at some point. So I need to create UAT and dev versions which would point to the UAT and dev databases. What I am struggling with is how to create these.
The namespace in my live, UAT and Dev databases need to be the same but if I create a new mobile service called myAppName_UAT, it's going to want to use MyAppName_UAT as the namespace and so will not find any of the tables.
Has anyone overcome this problem? Once the product goes live I'll need to be able to test the mobile apps against the Dev db without affecting live which surely must be a common scenario?
Any advice would be very gratefully received.
Edit: What I'm specifically after is how to manage the multiple environments within the Azure Portal. I can deploy all the other components of my UAT environment but I'm stuck on the mobile service.
I am not asking for a way for my applications to switch config files or to migrate data between databases. Does anyone have any experience of running azure applications with multiple components where they ran multiple mobile services?
Do you use a Version Control? For me, you just need to create branches to separate the 'UAT' and 'dev' versions.
About the databases:
You can use web.config transformations to switch the connection string between your databases.
http://msdn.microsoft.com/en-us/library/dd465326.aspx
How do I use Web.Config transform on my connection strings?
=================================================================================
Update:
Ok, now I understood what you want.
Create your two versions of mobile services:
1-Log in Windows Azure Management Portal (http://manage.windowsazure.com)
2-Create your test mobile services (if you already have then, skip this step):
2.1- New -> Compute -> Mobile Services
2.2- Url - MyMobileServicesTest
2.3- Database -> Create a new (test db).
3-Create your production mobile services (if you already have then, skip this step):
2.1- New -> Compute -> Mobile Services
2.2- Url - MyMobileServicesProduction
2.3- Database -> Create a new (production db).
Right now, you have two different versions.
Using Windows Azure SDK:
//public static MobileServiceClient MobileService = new MobileServiceClient(
// "AppUrl",
// "AppKey"
//);
Pay attention: AppUrl will be "MyMobileServicesTest.azure-mobile.net/" or "MyMobileServicesProduction.azure-mobile.net/". The app key, each environment will have it's own. You can store this settings in a config file and switch according to what you are doing.
More information:
http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started-with-data-dotnet/
Multiple mobile services can share the same database. You only need to specify the same schema name in web.config in each mobile service:
<appSettings>
<add key="MS_MobileServiceName" value="MyAppName" />
</appSettings>
Updated:
The setting above only works in localhost, but not after publishing to live.
Need to do the following trick in order to make it work. Just hard code the schema name into function OnModelCreating. This way the database schema name will not depend on the mobile service name any more:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
string schema = "MyAppName"; // ServiceSettingsDictionary.GetSchemaName();
if (!string.IsNullOrEmpty(schema))
{
modelBuilder.HasDefaultSchema(schema);
}
modelBuilder.Conventions.Add(
new AttributeToColumnAnnotationConvention<TableColumnAttribute, string>(
"ServiceTableColumn", (property, attributes) => attributes.Single().ColumnType.ToString()));
}

windows azure script services add message to queue

I'm using Windows Azure Mobile services to upload pictures from a mobile app. The mobile script services accepts the file, saves it's name to the database.
What I'm trying to do is to be able to add a message to a queue which will resize the uploaded image.
Do Script services supports calling queues from within or I have to make my app do that call?
Thanks in advance
You can use the following code to send a message to the queue:
var azure = require('azure');
var queueService = azure.createQueueService("myaccount", "mykey");
queueService.createQueueIfNotExists("myqueuename", function(error){ });
queueService.createMessage("myqueuename", "contentOfTheMessage", function(error){});

Resources