How to fully integrate in bb10 hub like WhatsApp? - blackberry-10

The latest version of whatsapp was integrated in bb hub. when click on message item for whatsapp in hub, will open a card UI that can send and receive message.
but it still able to send and receive message when I close whatsapp, how to achieve it?
Card and app has own process and context, need across-process communication(card communication with application)?

It has been reported, and widely held, though I have never seen any official documentation it is none the less probably true that the WhatsApp developers were given early access to Hub integration APIs that are not yet widely available to third party developers.

There's a good deal of information out there now for anybody looking to find it. There's a handy page on BlackBerry Hub Integration for C and C++ (native) developers. You basically need to use the UDS (Unified Data Source) Library to open a connection to the BlackBerry Hub and register your app with the Hub.
This page has a lot of example code related to Hub integration. The basic steps are:
Open a connection to the Hub.
Register your app with the Hub.
Retrieve your service ID via the UDS.
Add an account.
Add and manipulate inbox list items on the Hub.

Related

Can you trigger workflows and send data without user voice?

Suppose I had a bluetooth low-energy (BLE) device that periodically needed to send sensor data to my server. And I wanted to use a Google Home Hub as a proxy to send this data. Is it possible to send periodic actions or do all actions have to be triggered by a users voice?
From the documentation I see you need a Android App or Google Home App but can I build custom message interfaces without one?
This can be made to work using two important aspects for smart home integration :
Local Home SDK , which enhances your smart home integration with Google Assistant by adding a local fulfillment path to route smart home intents. More information about how this works can be found here, https://developers.google.com/assistant/smarthome/concepts/local
Seamless Setup using Bluetooth Low Energy . Since BLE devices do not have a companion cloud fulfillment implementation, asynchronous state changes must be reported locally through the Local Home SDK. We would need to implement the connection event handlers, AUTOCONNECT and DISCONNECT. Also, implementation for subscribing to notifications from BLE devices needs to be carried out using REGISTER_FOR_NOTIFICATION command to the device using the DeviceManager API. Other steps to be carried out are for reporting characteristic state changes through PARSE_NOTIFICATIOn intent handler. More information about working around with this can be found here, https://developers.google.com/assistant/smarthome/develop/seamless-setup#reporting_local_device_state

Socket connection between rails and iphone native app

I have an iphone app with rails serving as a backend server.
Now I need to implement a chat functionality using sockets connections.
A lot of examples show you how to implement chat using sockets in browser.
What I need here is how I can implement an application where you create socket server in the rails app , and the client in iphone app which listens to the channel I give them.
I tried using faye(examples given only how to implement client in the browser) and using fayeObjC library for iphone to create client, but am not able to listen to the channel from this library.I know I must be implementing it wrong here.
I'll share my code also here, but first I need to know is there a better solution than this?
Also I appreciate some links to some examples where socket server is in rails and clients are iphone app.
Appreciate any help and mostly need a right direction to implement it.
Update
I tried the faye combination again and it worked.Although still looking for more solutions.
You can check about TCP sockets:
http://www.raywenderlich.com/3932/how-to-create-a-socket-based-iphone-app-and-server
Chat Application Using Ruby
http://quickblox.com/modules/chat/
http://caydenliew.com/2011/11/ios-mac-os-communication-with-asyncsocket/
http://www.macresearch.org/cocoa-scientists-part-xxix-message
Next link is a comprehensive Networking Guide - Using Internet Sockets
You must keep in mind two major problems to peer-to-peer communications (Chat): reachability and how to receive new messages while your application is in the background (get notifications).
For the last you can use APNS approach: an invisible notification will be pushed to the iPhone indicating that a new message is ready to be read. So your app will make a request for unread messages (what app like WhatsApp does).
Besides TCP sockets you could use websockets (HTTP - so there are no firewall problems).
Best in class - Socket.IO.
Here you will find the wiki https://github.com/learnboost/socket.io/wiki (you will find there an extension for Ruby also)
Here an example for iOS chat client for socket.io & node.js backend
Jabber
Another option: XMPP - "stands for eXtensible Messaging and Presence Protocol. Such a protocol is open-standard and oriented to message exchange (builds and maintains by Jabber community). Message exchange happens near real time, so it is an ideal infrastructure to build chat-like applications. The protocol also implements a mechanism to notify presence information (whether a user is online or not) and the maintenance of a contact list. XMPP is a thorough protocol, which has been adopted also by big companies like Google to build their Instant Messaging service."
Here you will find all about developing a Jabber Client for iOS (enable users to sign in, add buddies, and send messages; how to install and configure a jabber server, create accounts, and interact with the server from an iOS application http://mobile.tutsplus.com/tutorials/iphone/building-a-jabber-client-for-ios-server-setup/
I know that SocketRocket by square is a strong native Objective-C library. But it doesn't offer the channel abstraction you seem to be looking for.
If you would consider outsourcing the WebSocket connections then you could use a hosted service like Pusher, who I work for. You can publish messages (trigger events) on channels using the pusher-gem. And you can subscribe to channels and receive messages using one of Pusher's Objective-C libraries.
Other solutions will also have Objective-C libraries and you can find a list of them via this realtime web tech guide.

Server framework to use for realtime iPhone app

I am currently writing an iPhone application that sends and receives JSON data from a remote server to essentially display realtime information. Me and my partner started the project using Google App Engine (Python) for the server-side implementation mostly because it was easy to pick up and seemed suitable for our needs at the time. However, we're only just now starting to see the downsides of the framework for realtime iPhone apps - APNS is not at all supported, and neither is the GAE Channels API. So our only option for displaying the realtime server data on our app is to continuously poll the server, which certainly seems like horrible design.
We'll have to port our server-side code to a new framework. My question is, which one do we use? From numerous searches, I still have yet to find a satisfactory answer.
I should mention that I don't necessarily want the server to send push notifications. I just want to be able to push data to clients in real-time, and then manipulate that data on the iPhone client-side code. We're fine with setting up the framework on a local server if we have to.
Since you don't want to be pull data in background (lett alone if it is even possible)will have to use APNS.
But why switch away from google app angine, you could use an APNS provider like Urban Airship wich provide there on API to connect with.
You'r not even the fist to run into this problem: Apple Push Notifications on Google Appengine
Probably the easiest realtime framework you can use for sending data to iOS clients in real-time is PubNub (http://www.pubnub.com). It's reasonably priced, and it scales to anything you can throw at it. In my experience, it has no problem delivering a message to an end client in under .25 milliseconds (regardless of the number of clients it's being sent to).
Their latest version also supports APNS functionality for when you app isn't in the foreground.
https://github.com/pubnub/objective-c/blob/master/iOS/README_FOR_APNS.md
If you want to create your own APNS server (since you are running on App Engine anyway), there are examples of how to do that using App Engine's new Socket API. I've written a demo python AppEngine application that people might find helpful in this regard.
https://github.com/GarettRogers/appengine-apns-gcm

How can a back-end server connect to a specific iphone?

It is very usual that an iPhone send data to internet server.
But what if a server wants to connect to an iphone?
I have wondered long about it.
For example, like many web-based apps like Facebook, what is the mechanism/algorithm behind, so that when, for example, any updates on your wall can be noticed to you in a real-time manner?
Hope some can understand my query.
Have a look at this Wikpedia article about Push Technology.
Push technology, or server push, describes a style of Internet-based communication where the request for a given transaction is initiated by the publisher or central server. It is contrasted with pull technology, where the request for the transmission of information is initiated by the receiver or client.
Your iPhone could intermittently 'poll' the server, looking for any data it needs to be sent. Say every 5 seconds, or after some trigger - it would call the server and ask for new data.
You could use push technology: i.e. have a continuous http connection open to your server that allows data to be sent both ways. LightStreamer is a product that does this that i've used before. This is the most elegant and efficient solution for streaming data.
You could use iOS push notifications. The server can trigger a push message and target it at a specific device and send your iPhone something...
Push notifications are the way to go with iOS. I have used push notifications through the cloud-based Cocoafish backend server. This is a great solution as you can 'subscribe' mobile devices to a push notifications channel - for example, a channel for friends requests or a channel for chat etc. Its real easy to set up with all the correct certification. There's good set up instructions in the documentation on their site too.

how to make my server support APNs?

i read in some stackOverflow post that The host would need to have port 2195 open and support push notifications under apns.how do i make my server to support apns.
what does this line means in Push Notification guide
To establish a trusted provider identity, we should
present this certificate to APNs at connection time using peer-to-peer authentication.
do i need to make a connection to APns through my native app? someone please explain this
Pretty much any server that doesn't have restriction on what sockets you can open is ready to be an APNS provider. In your project code, you can just open a socket to Apple servers (or use a library).
My understanding that Google App Engine and basically any traditional shared web hosting block any port other than 80, so you cannot use them. However, you can look into Urban Airship that provides a RESTful API that basically use from any service. It might get pricy though.
In short you need to establish an SSL connection, and then send the payload in the pre-defined binary format.
alt text http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Art/aps_provider_binary.jpg
See this guide for more details.
I use appengine, so I solved this by renting a super cheap server in hetzner.de. It basically serves as proxy to my appengine app and uses this library: https://github.com/notnoop/java-apns
that library has a one line way to send the message, using the certificate.
Google just opened up the ability to do Socket stuff on AppEngine, so I created a sample project that you can use to send push notifications using GCM and APNS in python. Feel free to use any of it that you like.
I've also included a sample iOS project and Android project that hook up nicely with the app engine solution.
https://github.com/GarettRogers/appengine-apns-gcm
** Full Disclosure ** this is my project, and I'm in no way trying to promote it because it's mine... it's simply the only available project that solves your problem at the moment. If you find anything that does a better job, please leave a comment.
You may check out java-apns-gae.
It's an open-source Java APNS library that was specifically designed to work (and be used) on Google App Engine.
https://github.com/ZsoltSafrany/java-apns-gae