Device registration via Rest API

I am building my mobile client application using HTML5, CSS3, and Javascript, so I need to be able to give the user the capability to register their mobile device for Push Notifications (iOS, Andriod, etc) using a REST API. Is this possible?

Hi Darel,

Registering a device with REST is easy, but… native push notifications require a native callback function/method in your app. The method is used by the OS to dispatch the notification to your app when the user selects it from the Notification center. I believe there is a way to do it with a PhoneGap plugin, but personally haven’t that approach.

Regards,
Mark

That’s a bummer and deal breaker for me! You can register or subscribe to notifiers with appMobi. Why can’t Backendless do this?

Receiving a native push notification (the one a device can get when your app is not running) cannot be done without native code. It is not even a limitation of a backend, that’s just how push notifications work. You can easily create a REST subscriber to get messages when your app is active, but once it is unloaded, you absolutely have to have native code (obj-c, java) in order to get the notifications.

I guess the only alternative is to download the provisioned files from (PhoneGap or Intel XDK), edit the source by adding the backendless code and recomplie.

Let’s brainstorm about it, we really would love to help you. This is a common problem and I am sure there are many others who wonder what to do in this case.

How do you package your app? Will it run in a browser on a device or it will be an appstore app which renders its content in an HTML container? The reason I ask is if it is the latter, then some sort of hybrid approach would work.

Mark,

Okay. I’m going to give you some background information on what I’m building, the tools and development environment, and OS I’m using to develop my apps.

Summary of project:

I’m building a client server application that helps business clients manage and connect with their employees on their mobile device. So, one of the applications I’m building is a Desktop Web App that allows a business user to do the basic things like login, logout, and some routine things like upload a list of employees from a csv file, edit employee records, add employees, etc. The Web app also gives the business user the ability to upload and manage employee work locations and assign employees to any of those locations from time to time. When this happens, I want to be able to send and email and a push notification at the same time to the employee’s mobile device to alert them of their new assignment.

Tools:
For this type of development, I’m using Intel XDK to develop the mobile application, and for the Web Application, I’m using Sublime, Plunker, and LightTable. On the backend, I want to use backendless.

Intel XDK:
The XDK will allow me to design, develop, and simultaneously publish my source code to Apple iTunes, Google Play, and Windows Store at the press of a single button. So, in the XDK I can write my HTML5 markup, drag and drop UI components onto the device simulator, and add JS libraries or write my own JavaScript code. It will also allow me to connect to external Web Services, typically a Rest API. What’s nice about that is, the XDK takes care of all the dependencies, provisioning, and packaging of my app for the app stores. It sometimes takes a few seconds for the XDK to process the code. After its finished, you can download the provisioned files (apk, etc) , open and edit the source in their respective environments (in XCode or Eclipse).

Development/OS environment:
I’m developing my app on Windows 8 using the tools described above. I will be using my Mac to order and download the certificate from Apple, and will do the testing on the XDK and on physical mobile devices.

Is backendless the right solution?
At this point, I’m evaluating three BaaS products; Dreamfactory, Apigee, and backendless. As you can see from the Use Case I’ve discussed, I really need a BaaS that can help me integrate my Web App and Mobile clients with backendless, especially the Push Notification service.

Push Notification is crucial to the success of my app.

Darel

Thanks for the information, Darel. I have studies XDK docs as well as pushMobi capability. My understanding is with the XDK a notification can be retrieved and processed only when the app is active (it must be started and running). Is this your understanding as well?

Mark,

At first glance it may appear so. But if you read through the LiveUpdate implementation guide, it seems as though the device can receive automatic updates without the user’s action. However, I’m not sure if that receiving push notifications works the same way. But looking at the appMobi JavaScript library, it does seem like there is a registration process that must happen initially before the device can receive any push notifications. Once registered, it will be able to receive messages, but I’m not sure if the App has to be running.

Please look at the two zip files I’ve attached. May they would make better sense to you!

ImplementationGuide-pushMobi.zip (856.05kB)

ImplementationGuide-LiveUpdate.zip (362.8kB)

Darel,

I looked into it and it appears a pure JS implementation (no native code). It will be able to process notifications only when the app is running. They actually talk about it in the implementation guide (see the “Notify the Application” section):

“The final option puts control of the update completely in the hands of the developer and allows them to code their application to handle the update by themselves. Once an application is available, the application will be notified either at startup through the AppMobi.updateAvailable parameter or during runtime through the appMobi.device.update.available event”

That said, you can do everything they offer (plus a lot more) with Backendless. However, if you are looking for pure push notifications which can be delivered to a device without the app running, it would require native code. I believe PhoneGap makes it possible if you are building a JS app.

One option you have is to make it a hybrid app. That is it will run as a native app in an HTML container, but with some additional native code which would handle the notifications the traditional way. Do you know how to go about it?

Regards,
Mark

Hi Mark,

I don’t know how to do it and I’m going to need some guidance here. Can you help steer me in right direction?

Hi Darel,

I do not have any hands on experience with XDK so I cannot speak from the experience. Do you know if their dev environment gives you a web app which does not have any of the OS wrappers they add on top of it? In other words do you have a pure HTML/CSS/JS app which you can load on a device in a mobile browser?

Regards,
Mark

Mark,

I don’t have a pure HTML/CSS/JS app like that at the moment. But how would you build a system like the one I’ve described earlier with Push Notifications? Should I use appMobi or backendless for that?

Hi Darel,

Since you are using XDK which does the compilation and packaging of the app for you, you would not be able to get pure, native push notifications (the ones which show up when the app is not running) neither with appMobi, nor with Backendless. The functionality which appMobi offers IS available with our platform as well. The trade off though is the notifications are pulled from the server when the app runs (or on demand while it is running). Please let me know if you are interested to learn how you can accomplish it with Backendless and I’ll share the details about the API with you.

Regards,
Mark

Mark,

Let me know the details about the API.

Like a ghost stumbling upon old threads, i found this as i am looking for the same, and i think the question can be reframed.

I am using Intel XDK to develop a hybrid app.

I can register my app for native push notifications, by using this Phonegapp plugin which does just that.

Thus i can get the registration ID of the device and the plugin handles by itself all the native os logic. The only problem i come across is that i cannot tell Backendless that this is my registration ID or token (iOS), thus BE cannot send push messages to my device.

This could be solved by having a JS Api call that would take as a parameter this info (along with the platform) and register the device on Backendless, which is what i think both native API (iOS and Android) do.

Do you see this solution feasible?

Nicolas,

The source code of the library is available for you. How about making a change and seeing if it makes it work for you? Let us know if you can confirm and we’ll make the official change.

Regards,
Mark

Alright, i can do that.

Yet, how do i tell BE to register a device, not simply a webpage? i mean, on your servers, what parameters will it receive to register a device for one platform or the other?


function (channelName, subscriptionCallback, subscriptionOptions, async) {
            var responder = extractResponder(arguments);
            var isAsync = responder != null;
            if (isAsync) {
                var that = this;
                var callback = new Async(function (props) {
                    async.success(new Subscription({
                        channelName: channelName,
                        options: subscriptionOptions,
                        channelProperties: props,
                        responder: subscriptionCallback,
                        restUrl: that.restUrl,
                        onSubscribe: responder
                    }));
                }, function (data) {
                    responder.fault(data);
                });
                this._getProperties(channelName, callback);
            }

Can you be more specific? For what platform do you need to register a device?

Android and iOS.
i want to use the JS api (or REST) to register iOS and Android devices. To tell Backendless, look, this is the id of an iOS or Android device i want to register in your platform, don’t worry about how do i get the notifications from the native os, just register them in the server so i can send them push notifications.