Is it possible to prepolulate an AWS AppSync iOS client? - ios

We’re looking at using AWS AppSync for our next mobile project because of its offline capabilities. Using AppSync is it possible to release a mobile app (iOS / Android) with the mobile app database prepopulated with content? This is to avoid a slow mega content download the first time the app connects after being installed.

Yes, this is possible to do. The appsync client allows you to specify your database location as part of the config. Here is some sample code that shows you how it is done
// Set up Amazon Cognito credentials
let credentialsProvider = AWSCognitoCredentialsProvider(regionType: CognitoIdentityRegion, identityPoolId: CognitoIdentityPoolId)
// Specify the location to your custom local DB
let databaseURL = URL(fileURLWithPath:NSTemporaryDirectory()).appendingPathComponent("custom_db_name")
do {
// Initialize the AWS AppSync configuration
let appSyncConfig = try AWSAppSyncClientConfiguration(url: AppSyncEndpointURL, serviceRegion: AppSyncRegion, credentialsProvider: credentialsProvider, databaseURL:databaseURL)
// Initialize the AWS AppSync client
appSyncClient = try AWSAppSyncClient(appSyncConfig: appSyncConfig)
....
You can use this mechanism to include the pre-populated database in your app and then configure appsync with that path for the database.

Related

How ios app data connect to azure sql database?

I am new xcode and swift lanuage, I am making a ios application with xcode, it is a qr code genrator and I want to make qr code data sync to azure sql database, but I don't know how to write the function to sync data to azure sql database. How should I write the function to sync the result of qrcode generator to azure sql database?
Here is my qr code generator Code:
func Generate(id:string)-> UIImage {
let com = id.data(using: .utf8)
filter.setValue(com, forKey: "inputMessage")
if let qr = filter.outputImage {
if let qrImage = cont.createCGImage(qr, from: qr.extent){
return UIImage(cgImage: qrImage)
}
}
return UIImage(systemName: "xmark") ?? UIImage()
}
how could i sync the result data to azure sql database? do any experts know how to write the function?
To connect with IOS app first you need to create mobile app in azure portal.
for that you can follow below procedure:
Go to search bar in azure portal and search for app service click on that and create new by giving required details:
Click on create, after deployment go to configuration under settings and click on new application settings. In the Add/Edit application setting page, enter Name as MobileAppsManagement_EXTENSION_VERSION and Value as latest and hit OK.
for creating database connection Download the client SDK quickstarts for the following platforms:
iOS (Objective-C)
iOS (Swift)
Android (Java)
Xamarin.iOS
Xamarin.Android
Xamarin.Forms
Cordova
Windows (C#)
Create Azure sql database and copy the connection string of database:
Server=tcp:<server>.database.windows.net,1433;Initial Catalog=<db>;Persist Security Info=False;User ID=demouser;Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
Add the connection string to your mobile app In App Service, you can manage connection strings for your application by using the Configuration option in the menu.
To add a connection string:
Click on the Application settings tab.
Click on [+] New connection string.
You will need to provide Name, Value and Type for your connection string.
Type Name as MS_TableConnectionString
Value should be the connecting string you formed in the step before.
If you are adding a connection string to a SQL Azure database choose SQLAzure under type.
In this way you can connect azure SQL database to IOS app.
for more clarification you can refere
1.Create an iOS app - Azure Mobile Apps | Microsoft Learn
2.https://social.msdn.microsoft.com/Forums/en-US/f50195df-0fab-4361-82ac-e75a338b69cc/connect-to-azure-sql-database-from-ios-app-written-in-swift

Get Firebase database from another firebase app

How to access firebase database from another firebase app in swift5?
We have two apps in one account one is driver app and rider app.
I am storing data in driver real time database and want to access that database in rider app.
Let me know if anyone have this solution.
To access the same database from two iOS application, you simply create two apps in the Firebase console of that project. This will give you a GoogleService-Info.plist file with information about both apps, and each app will pick its configuration from there based on the iOS bundle ID.
Also see step 2 of register your app in the Firebase setup instructions for iOS developers.
After this both apps can access the same database, as well as all other services.
Here is code to use multiple firebase database in a single iOS app
func initDatabase() {
FIRDatabase().database() // gets you the default database
let options = FIROptions(googleAppID: bundleID: , GCMSenderID: , APIKey: , clientID: , trackingID: , androidClientID: , databaseURL: "https://othernamespace.firebaseio.com", storageBucket: , deepLinkURLScheme: ) // fill in all the other fields
FIRApp.configureWithName("anotherClient", options: options)
let app = FIRApp(named: "anotherClient")
FIRDatabase.database(app: app!) // gets you the named other database
}
Or you can initialize from another named plist rather than a huge constructor:
let filePath = NSBundle.mainBundle().pathForResource("Second-GoogleService-Info", ofType:"plist")
let options = FIROptions(contentsOfFile:filePath)

How do I upload an image from iOS app (built with Kony) to AWS S3 using aws-sdk for javascript?

I am using Kony Visualizer (a low code platorm) to build a mobile app (builds an iOS and Android native app) that can post images taken by the user to an s3 bucket. I am currently using the aws sdk for js (easy import into this low code platform) and am trying to use an s3.putObject call to push the image up. I have found that I can push the base64 string of the image's rawbytes to s3 storage from an Android device, but am unsuccessful in doing so from an iOS device. I have posted this on the Kony forum too at this link and will paste my code below. Also, I know the connection to s3 is working, because I am posting csv files to the same bucket in another part of my code.
AWS.config.update({
accessKeyId: <accessKeyId>,
secretAccessKey: <secretAccessKey>,
region: <region>
});
var rawImg = this.view.Picture.rawBytes;
var b64img = kony.convertToBase64(rawImg);
var bucketImage = new AWS.S3();
var paramsImage = {
Bucket: <bucket-name>,
Key: "images/imageB64.jpg",
ContentType: 'image/jpg',
Body: b64img};
bucketImage.putObject(paramsImage, function(err,res){
if (err) {
alert(err);}
else {
alert('Success');
}
});
If you continue having trouble doing the photo upload using the AWS SDK for JS, try the alternative route of creating a Foreign Function Interface (FFI) and using the AWS SDK for iOS. That's how the developer on my team got S3 uploads working in our Kony app.
He used the AWSS3TransferManager and AWSS3TransferManagerUploadRequest classes to do this.
Here's a code example in Swift
I'm sure the FFI option would have worked, but I found that once I added the App Transport Security Settings -- Allow Arbitrary Loads - YES to my Info.plist in Xcode, and , these uploads started working. Apparently this uses http headers, which iOS doesn't automatically allow. I also had to add the following JSON to my infoplist_configuration.json file under my project in Kony Workspace:
"NSAppTransportSecurity" :
{
"NSAllowsArbitraryLoads" : true
}

How to create permanent group using ejabber xmpp in iOS

Note:- Before down grade question read description.
We are implement ejabberd for chat application personal chat working fine with all functionality. now we need to create permanent group using ejabberd MUC/SUB service.
We read https://docs.ejabberd.im/developer/xmpp-clients-bots/proposed-extensions/muc-sub/ documents.
Now my question is that how we can send all this IQ using iOS if you guys have any demo or sample code then share here.
We also try with PHP rest API but not getting any presence or ping into iOS application.
Ejabberd never remember groupJID which is created by us. but you can achieve with the help of web service by storing group info while creating group and every-time fetch group info from server and join manually,
let xmppRoom = self.getRoomObject(roomJid: roomID.appending(GroupConfernce))
let history = DDXMLElement.element(withName: "history") as! DDXMLElement
history.addAttribute(withName: "maxstanzas", stringValue: "10")
xmppRoom.addDelegate(self.appDelegate, delegateQueue: DispatchQueue.main)
xmppRoom.join(usingNickname: self.appDelegate.xmppStream?.myJID.user, history: history)
otherwise you can use MongooseIM Server, it has capability to remember group info and no need of any manual process.
check below link
https://github.com/esl/MongooseIM

Integrating AWS analytics to Swift Application

I am currently working on an iOS app using app. I want to add AWS mobile analytics to my app but I've been having a difficult time doing so. I followed AWS get started guide but it doesn't work. I imported AWS using Cocoapods.
In the guide, the code to initialize AWS mobile analytics is here (it is in objective-C) :
AWSMobileAnalytics *analytics = [AWSMobileAnalytics mobileAnalyticsForAppId: #"myAppID"
identityPoolId: #"myIdentityPool iD"];
I don't know much about objective-C, but I translated it to swift like this:
var analytics: AWSMobileAnalytics = AWSMobileAnalytics(mobileAnalyticsForAppI:"myAppID", identityPoolId: "myIdentityPool iD")
When I went back to the aws analytics dashboard, nothing showed up. Am I missing something here?

Resources