Candy chat on phonegap app - javascript

I'm currently working on a project for a student led program at my school to make a mobile application that involves advertising various events and such, but more importantly, allows the app users to chat to one another. My question has to do with this chat functionality. I have heard good things about candy chat, and thought I might try to use it. The issue I have run into is setting up the XMPP server.
The program I'm doing this for has a very limited budget, so I have to find the cheapest solution possible to host this XMPP server. The idea I had, was to somehow use Google's App Engine or a similar cloud computing platform with a good free offering as the backend chat server. So, my question is, does anyone have any experience in doing something similar to this who can give me a better idea of how to accomplish it? Not necessarily with the exact same tools, but at least a similar concept.
Also, if I'm going in the totally wrong direction, feel free to set me straight. I'm still in the very early stages of this project, so I'm not really tied to any aspects of this solution, this just seemed to be the most straightforward way to go to me.
Thanks guys!

Since you seem to have a budget constraint, I would suggest going with the free tier of Amazon's EC2 service (Google App Engine won't work as it only lets you implement an xmpp client, not a server). You can host any XMPP Server on your Amazon EC2 instance. Ejabberd seems to be a popular choice.
I think you're in the right general direction, once you have your XMPP Server installed and running, you can easily connect whatever client you want to it.

Related

Stripe integration in an Expo managed project

I’m very new to programming, I know I’m not supposed to ask here, but I really got lost, I’m building a food ordering app with Expo and the only thing left for me is to add Stripe and building the iOS and android projects. I’m really confused on what are the next steps, some people talk about ejecting and then developing Stripe. The expo documentation just provides examples in TypeScript, and my project is in JavaScript. And the Stripe documentation talks about a “server-side” which I still can’t understand how it works, for example, when I launch then my app in the stores, do I have to run the server in my computer separately at all times when the app launches? Also I should add that I’m using Firebase for Authentication and Databases. If someone could provide me good tutorials or have some suggestions I’d be glad, thanks
Usually StackOverflow is for very specific question, not "global" how-tos, I won't then write code for you, but will try to explain as much as I can.
First of all welcome to the amazing world of programming ! One of my mentor oftenly says "Developer can change the world with a text editor".
Concerning your Expo App : No you don not need to eject to use Stripe, the great expo team is providing a brigde between #stripe/stripe-react-native and expo. You can read more here.
For the demo, just remove the typescript params, it should work like a charm (thus, as you're new to programming, I strongly recommend you to check typescript, as it's (almost) now a standard for JS programming, both front and backend).
For the backend part, yes, you'll have to create your own, raw - using the JS runtime Node.js (Express, Nest, Koa...), PHP, Python or any language you're familiar with, or a "serverless" one, you've mentionned Firebase, it's one of it, bit there're many solutions out there (AWS Lambdas...)
Of course, you won't have a backend on your computer, but on a dedicated server which will handle every call from your app serving from 'https://myapi.mydomain.com/what/to/do'. Imagine your app as a shop, a visitor can see shoes, try them, and if he/she wants it, he has to pay.
And here, usually the shop needs some customer informations (for retargeting) and stock management (Hey ! 4 customers has bought Shoes #42 in Size #4 and Color #17, we should reorder some), that requires a bit a security and business logic (confirm payments, send orders, ...).
Concerning Stripe, you'll need a backend to create a Customer cus_XXX, create a Payment Intent, send it back to your app and confirm it then (for Europe 3D Secure, or SCA stuff), it's slightly more complicated, i took the quickest path.
For the tutorials, there's PLENTY, if you can afford $10 to $50 check the insanely good ones from Udemy or Pluralsight otherwise, check Medium or just ... Google it with "Node.js getting started".
As you're new in programming, and as SO is slightly for more "advanced" peeps, I'd recommend you to find some dev community on Slack / Discord, you'll probably more "welcomed". At some point we're all the junior of someone, but this place is - once more - for very specific questions ;)
Happy programming !

Web Application - Reactjs - It is possible to make a great score on SEO with exclusively client side rendering's Web application in 2018?

I so much love the flow of client-side applications, but wonder if it possible to make great SEO with that. That what I ask if in 2018, it is possible to make an as well SEO on client side rendering exclusively ?
I know there is some topics on this subject but the answers are very olds regarding the evolution of technology.
I have heard about Gatsby.js. The difficulty is that, after testing it for few days, maybe I'm wrong but seems Gatsby can't access to backend when building application. Hence it's would be difficut to build some specific features as socket.io or other thing similaries.
Any hint would be great,
thanks

Chat system implementation

I am required to implement a live chat system, somewhat similar to Facebook's in that it must:
Allow communication between 2 users
Store messages in an inbox/sent box
Store messages in inbox, marked unread if the user is offline when a message is sent
A language/spam filter must also be active, as needs to monitor communication involving minors.
Ideally, this will work on most devices/browsers including mobile access.
I pretty much have a blank canvas for this project in terms of what OS/software to use.
Having done a bit of research it seems like there's a few options / things to think about?
PHP/AJAX long polling (Comet-style) with a standard LAMP stack storing messages in a mysql DB
LEMP stack (nginx)using the HTTP Push Module, again Comet-style server with a php backend storing messages in a mysql DB
Node.js?
HTML5 interface to maintain browser/device support?
Best DB system for this? Some people suggested mongoDB?
Some people also suggested utilising MemCacheQ to boost performance.
What are your thoughts this? Any suggestions?
Check out SignalR as the way of passing the messages between clients, it's the easiest way to create a chat application.
This sounds like the sort of thing that the MEAN stack (MongoDB, Express.js, Angular.js, Node.js) combined with either socket.io, or lightstreamer would be good at. Lightstreamer is supposedly faster and more scalable than socket.io (and their live demo's don't make me doubt that), it also has a page in their documentation discussing PhoneGap (they handle phones that don't support WebSockets...which is useful, because, as I understand it, WebSockets aren't supported by most phones)
This isn't my area of expertise though, but it may be worth researching.

Javascript Client Authentication (with SSL, without OAuth2)?

The scenario is:
I have a web API, which is being accessed by two clients:
Web App written in Javascript, which is minified
iOS App
SSL is all set up on the server hosting the API, and it works fine. There is no User Auth for the API because it's a sort of location-based searching app.
I want to ensure though that only the web app and the iPhone client are able to actually make requests to the API. For the iPhone client it's easy - a shared secret between the server and the app will do, and it's encrypted with SSL so we're not worried about people spying on it.
But for the web app the same solution won't work. I can't just leave a string in the code, and even if it's encrypted in there that's all somebody would need.
Basically, I'm looking for a good solution to this problem. I just want to make sure it's kept only to clients who are allowed to use it, but I'm not sure how I can without going and implementing OAuth which I think is probably overkill. Any ideas?
Thanks!
Dan
It can't be done. Even with oauth. Even assuming that your iOS app is secure, is wrong: it can be decompiled. Any code that runs on the client, can be tampered with, and can't be trusted to be who he says he is.
Only question is: is the API you provide valuable enough, and how much trouble would someone want to go through to hack it. And how hard do you want to make it for whomever wants to hack it.
The iOS version is indeed way safer than the javascript version. In the webapp you can obfuscate your code to make it harder to hack. You can (if you don't intend to use it on iOS) use java or flash to further hide your signing code (HMAC-sign your requests, don't just send a shared secret with them. You may think SSL is secure, but there is a moment before the url is encrypted....).
The way the "big guys" deal with this is:
Whatever you build, assume that someone will be able to hack it (as in: use your API for some other purpose than you intended).
Think about how bad this really is (note: they wouldn't be able to build a business on it; it would be WAY TOO vulnerable to lawsuits). Is it really the end of the world if a lone wolf uses your API.
If you do care about the lone wolves, make it as hard as possible (but honestly, isn't it cheaper just to loose some money from the lone wolves, than to spend 2 developer-months on it?)
If somehow there is serious interest in hacking into your API, try to come to an understanding with the hackers (e.g. I like the way how Spotify reacted to despotify. Basically they said "hey, if you don't release anything that makes it really easy to steal our music or circumvent our businessmodel, we won't try too hard to block you")

Turn based multiplayer for iOS using CouchDB and IrisCouch

Me and my startup app company is working on a turn based multiplayer iPhone application. Let it be said that neither one of us have any database, or server, knowledge whatsoever. Though, we are willing to learn.
The flow of the game will be similar to such games as: WordFeud, WordsWithFriends, Rumble etc.
Let me start of by where a lot of searching on the web has gotten us:
We have decided to use CouchDB as a tool for storing information about users, game sessions and other stuff. CouchDB is an open source noSQL database system. The reason is that we have been taught, that it should support a lot off concurring users. Besides, that it scales - we are hoping to go big, of course.
Our CouchDB, is hosted on IrisCouch. IrisCouch is an "in cloud" hosting service designed for running CouchDb.
So, we've got a CouchDB server up and running, and we know the basics on how to query data from the server.
Our biggest confusion right now, is how we should set up the system to work according to best practices. Right now we are at the point where we are able to receive and submit data to the server.
Our game is supposed to have Facebook integration, so that the users can register via our app or through Facebook. After that they can play with random matched opponents, or play with friends. After a match is started, one player will get a set of question to be asked, after he has answered, the other player should be notified, through push notification, that it's their turn. After a few rounds the game is finished.
At this point, we think this might be the best solution for the flow of the application:
A user connects to another user -> a game session is opened as a
document in a database called "games".
The newly created document contains both player names, question,
answers etc
A field named "whos_turn" decides which of the two players turn it is.
After the game has ended, the session is erased.
Again, and as you may see, we are in the dark as of how to really do it, but this is the general idea.
So, my questions goes as following:
Is it best to query the data directly from the iPhone application, or through a web service?
What is the best way to set up the database, to best manage the flow of the application?
Any information, that could lead us closer will be gladly appreciated :)
In advance, thank you!
Olav Gundersen
EDIT#1 : Our Objective-C programmer managed to connect two iPhone devices using CouchDb. The iPhone application consists of a table view, that has a concurrent connection with the database, so that when someone POST to the database, it shows up on the tableview of all the other connected phones. Behold: a severely ineffective chat system.
If is a multiplayer you would need to have the app to communicate to the remote iriscouch.db but I am concerned by the point where you state that neither you or your friends have any database experience. You are willing to learn so I think the best place to start is:
http://guide.couchdb.org/editions/1/en/index.html
There are several issue you might find with scalability if you plan to erase documents continuously. DB Size can be considerable on couchdb and you will need to compact &cleanup the db regularly. But I don't think is a major issue for now as this is at a start up level.
The question "best way to setup the database and best manage the flow of the application" should be addressed by your team. If you do not have someone with any database experience you should try to find someone willing to help you. It should be someone with extensive experience in databases. You might find some fairly reasonable professionals at http://www.odesk.com
In total honestly I don't think you will be successful if you don't have such a figure - either as a freelancer or contributor - to help you having a solid database logic in the game that will ensure a great user experience.
For example: have you considered the latency-delay issue by using a db based in the USA (Iriscouch) vs. where your users are located?
For this reason you might want to do as much as possible client side (embedded database like sqlite or touchDB that is essentially couchDB for iPhone)
For an iPhone application you might want to try TouchDB that is made exactly for that
https://github.com/couchbaselabs/TouchDB-iOS (caveat: being that you need connectivity to check turns etc this might not be the ideal solution but it could work to store some information locally).
To lay this out you would need someone with experience with couchdb to set up a proper, usable application. There is nothing wrong in being enthusiast about your idea but to make it a success you need a technical mind in the database side. Of course you might be well capable to learn this yourself. After reading the CouchDB book you should be in position to create a basic flow to fit your needs.
Of course other more experienced users might come with a more comprehensive answer or a sample layout but I don't think would be the best approach. Even if someone posts a full layout of the doc structure and how to query it how are you going to service the app if something goes awry e.g. sessions don't get deleted, conflicts etc. ? hence my sincere advice to get some ad-hoc expertise for your case.
This might also result in analyzing suitable alternatives. I don't think you should buy into the idea that CouchDB can scale and hence is the best/only option for you (of course this might well be the case and if you feel that is a good option..go for it). For example twitter, google adwords and many other online apps are using mysql to store their data so for sure CouchDB is not the only database that can scale!
I think this demo app could be a good example to follow: iOS Couchbase Demo

Categories

Resources