0

Send a notification when the app is in background (iOS)

asked 2014-08-05 06:27:05 -0700

spark86 gravatar image

Hi, I need to implement a simple mechanism for synchronizing data between multiple iOS devices. The synch is achieved through a simple exchange of strings, and I thought to try the Notification Service Framework to reach this goal.

I downloaded the Notification SDK and did some testing with the sample project inside the SDK. I tested it with three devices; for simplicity let's call them A, B and C.

Let's suppose that the device A should synchronize some piece of data with the other two devices through a notification, which for simplicity I will call it "N".

In summary:

Device A -> Producer (It sends N to the other two devices)

Device B -> Consumer

Device C -> Consumer

There are three scenarios of my interest, and I have analyzed one at a time.

1 °Scenario

Initial state: A -> foreground, B -> foreground, c -> foreground

1) A sends N

2) B receives N

3) C receives N

The first scenario is correct with what I expected.

2° Scenario

Initial state: A -> foreground ,B -> background, c -> background

1) A -> sends N

2) B -> enter in foreground

3) B -> receives N

4) C -> enter in foreground

5) C -> receives N

The second scenario is correct with what I expected.

3° Scenario

Initial state: A -> foreground, B -> background, c -> background

1) A -> sends N

2) A -> enter in background

3) B -> enter in foreground

4) B -> does NOT receives N

5) C -> enter in foreground

6) C -> does NOT receives N

7) A -> enter in foreground

8) B -> receives N

9) C -> receives N

This scenario does not reflect what I expected.

To reach my goal, what I expected is the following scenario:

Initial state: A -> foreground, B -> background, c -> background

1) A -> sends N

2) A -> enter in background

3) B -> enter in foreground

4) B -> receives N

5) C -> enter in foreground

6) C -> receives N

Is it possible to implement my three desired scenarios? If yes, can you suggest me a possible solution?

Thanks in advance.

edit retag flag offensive close merge delete

Comments

@spark86 The Notification Service is designed such that any device capable of rendering a notification will show it. IE whatever you put in the notification as text may show up on TV's that support AllJoyn or other devices.

bspencer ( 2014-08-06 01:37:40 -0700 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2014-08-11 12:59:35 -0700

bspencer gravatar image

The problem you face is very specific to iOS development and not AllJoyn. When the application enters the background it isn't actually running anymore unless you specifically add software to allow your application to multi-task or run in the background. Therefore your 3rd case is not possible unless you go about designing your application to handle being alive when not in the foreground.

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2014-08-05 06:27:05 -0700

Seen: 383 times

Last updated: Aug 11 '14