Since we have setup our ContactMobileAppController we should change our ContactsServiceProvider to make use of those RemoteActions.

Update ContactsServiceProvider

Since our app was a working copy of a Local Hybrid app we already have a service provider in place that works. Because of this we will not create a new one. Instead let’s modify it so that it has the same methods, including parameters and return values, but makes use of RemoteActions instead of ForceJS.

I’m going to keep a copy of the ContactsServiceProvider that uses force.js in a folder called /contacts-service.forcejs/. This way I can switch between the 2 different versions by changing a small portion of the import statement.

We can remove the import of the OAuth and DataService from forcejs and the force declaration we had.

One thing we will need to do is tell TypeScript about the Visualforce remoting by declaring it. This will allow us to call the global JavaScript object that is inserted into the page.

This private method will allow us to make calls to remote actions without having to copy and pastes all the parts that would be the same for each call.

For the rest of the methods we will be replacing the use of the OAuth and DataService with a call to our callRemote method. We do this in a Promise and provide the name of the RemoteAction to call, any parameters, along with the resolve and reject for the promise.

I will just post the updated methods bellow. If you have any specific questions feel free to email me brett@wipdeveloper.com or leave a message bellow.