Search form

Documentation

AllJoyn™ Notification Framework API Guide – Objective-C

Using the Notification Service

There are two ways to use the Notification Service, as a Producer and as Consumer. The power of the Notification service is its simplicity and ability to allow devices to "talk" to end users to provide meaningful information.

The Notification Producer side of an application is responsible for sending a sessionless signal that contains a small amount of text with some optional values. This text is intended to be rendered on any device that contains the Consumer side of the Notification Service.

The Notification Consumer side of an application is responsible for registering to receive the sessionless signal from any application that supports the Producer side of the Notification service.

An application can be a consumer, a producer, or both.

Reference code

Source code

Component Description
AllJoyn™ The AllJoyn Standard Library code
NotificationService Notification service framework code
ServiceCommons Code that is common to the AllJoyn service frameworks
SampleApps Code that is common to the AllJoyn service framework sample applications

Reference iOS application code

Application Description
NotificationService An iOS application of both a producer and consumer.

Prerequisites

Follow the steps in the Building iOS/OS X section to get your environment and project setup to use the AllJoyn™ framework and the Notification Service.

Build a Notification Producer

The following steps provide the high-level process to build a Notification Producer.

  1. Create the base for the AllJoyn application.
  2. Implement the ProperyStore and use this with the AboutService in server mode.
  3. Initialize the Notification service framework and create a Producer.
  4. Create a notification, populate the necessary fields, and use the Producer to send the notification.

Build a Notification Consumer

The following steps provide the high-level process to build a Notification Consumer.

  1. Create the base for the AllJoyn application.
  2. Create a class that implements the NotificationReceiver.
  3. Initialize the Notification service framework and provide the receiver implementation.
  4. Start receiving notifications.

Producing Notifications

General AllJoyn Setup

Initialize the AllJoyn framework

See the Building iOS/OSX section for instructions to set up the AllJoyn framework.

Create bus attachment

AJNBusAttachment* bus = ;
} else {
  [self.logger infoTag:;
}

Advanced Features

  • Audio
  • Image
  • Custom Attributes
  • Delete the last message sent

Consuming Notifications

General AllJoyn Setup

Initialize the AllJoyn framework

See the Building iOS/OSX section for instructions to set up the AllJoyn framework.

Create bus attachment

AJNBusAttachment* bus = [[AJNBusAttachment alloc]
  initWithApplicationName:@"CommonServiceApp"  
  allowRemoteMessages:true];
[bus start];

About Feature Setup

Create Notification Consumer

Initialize the Notification service framework

AJNSNotificationService *consumerService;
self.consumerService = [AJNSNotificationService sharedInstance];

Implement the notificationReceiver interface (receive and

dismissMsgId methods)

- (void)receive:(AJNSNotification*)ajnsNotification
{
  // application logic to handle the received notification
}

- (void)dismissMsgId:(const int32_t)msgId appId:(NSString*)appId
{
  // application logic to handle the dismissed notification
}

Start the Notification consumer, providing the bus attachment and Notification receiver

// Call "initReceive"
status =
  [self.consumerService startReceive:self.busAttachment withReceiver:self];

if (status != ER_OK) {
  [self.logger fatalTag:[[self class] description]
    text:@"Could not initialize receiver"];
  return ER_FAIL;
}

Refer to the Notification Service Sample App source code and API documentation for examples and more details.

For future news and updates, please follow or visit https://t.co/MKr1Z9NPji
9 months 2 weeks ago