Skip to main content
Inspiring
February 5, 2021
Question

Message feed for Android.

  • February 5, 2021
  • 1 reply
  • 378 views

I looked for some tool that could help me in the development of a message feed, but I didn't find anything that could guide me. See the example image: https://prnt.sc/ydeq1k

 

Basically the message is typed in a secondary location, and replicated on the Animate stage through ActionScript 3.

Could someone please give me a light? Thanks in advance.

This topic has been closed for replies.

1 reply

JoãoCésar17023019
Community Expert
Community Expert
February 5, 2021
vvvverTAuthor
Inspiring
February 5, 2021

Hello, João, how are you? That way, would I have to look for a dedicated server, or something? Because the initial intention would be to keep these messages visible to everyone who has the APK.

I saw that the structure was made through SWF, can you help me how it would work?

JoãoCésar17023019
Community Expert
Community Expert
February 5, 2021

I would go with Firebase. It's a service, so you won't need to setup any server. You'll need to only learn to access their REST API.

 

The user phantom, from the link I sent to you, has a sample of a chat functionality in this link:

https://github.com/PhantomAppDevelopment/pizza-app

 

These are two functions from the Pizza App he developed:

protected function loadMessages():void
		{
			var header:URLRequestHeader = new URLRequestHeader("Accept", "text/event-stream");
			var request:URLRequest = new URLRequest(Constants.FIREBASE_CHATROOM_BASE_URL + _data.selectedRoom.id + '.json?auth='
					+ _data.FirebaseAuthToken + '&orderBy="timestamp"&limitToLast=100'); //We are always loading the last 100 messages
			request.requestHeaders.push(header);

			messagesStream = new URLStream();
			messagesStream.addEventListener(ProgressEvent.PROGRESS, progress);
			messagesStream.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
			messagesStream.load(request);
		}

 

private function sendMessage():void
		{
			if (messageInput.text != "") {
				sendButton.isEnabled = false;

				//We prepare the vars to be send to the database, including the logged-in user basic info
				var myObject:Object = new Object();
				myObject.message = messageInput.text;
				myObject.timestamp = new Date().getTime();
				myObject.senderId = Main.profile.localId;
				myObject.senderName = Main.profile.displayName;

				var request:URLRequest = new URLRequest(Constants.FIREBASE_CHATROOM_BASE_URL + _data.selectedRoom.id + ".json?auth=" + _data.FirebaseAuthToken);
				request.data = JSON.stringify(myObject);
				request.method = URLRequestMethod.POST;

				var loader:URLLoader = new URLLoader();
				loader.addEventListener(flash.events.Event.COMPLETE, messageSent);
				loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
				loader.load(request);
			}
		}

 

It uses Starling, but it should give you an idea of how to write to and read messages from Firebase.