There’s problem sending push notification.
I am using Messaging service only for sending push notification.
sending iOS push from backendless console
I’ve managed send push notification to iOS devices using default channel.
However, push is not sent channel that user created.
For subscribing to a channel, I call the following API - it succeeds all the time
-(void)subscribe:(NSString *)channelName response:(void(^)(BESubscription *))responseBlock error:(void(^)(Fault *))errorBlock;
I even tried calling following API to see test if passing subscription option has any effect (examples codes from code gen passes empty subscription options)
sending iOS push from device.
I am testing with two iPhones, each subscribes to channel named after userId, which is done in the same way in code gen chat example.
I tried to send push notification from one device to another.
http://backendless.com/documentation/messaging/ios/messaging_message_publishing.htm
A)
As explained in above link, I called below API - there’s no error, push is not sent, and message is not displayed in console.
-(void)publish:(NSString *)channelName message:(id)message deliveryOptions:(DeliveryOptions *)deliveryOptions response:(void(^)(MessageStatus *))responseBlock error:(void(^)(Fault *))errorBlock;
B)
So I tried calling below API - there’s no error, push is not sent, but sent message is displayed in console.
-(void)publish:(NSString *)channelName message:(id)message publishOptions:(PublishOptions *)publishOptions response:(void(^)(MessageStatus *))responseBlock error:(void(^)(Fault *))errorBlock;
C)
Calling below code returns no error, push is not sent, message is not displayed in console.
(MessageStatus *))responseBlock error:(void(^)(Fault *))errorBlock;
-(void)publish:(NSString *)channelName message:(id)message publishOptions:(PublishOptions *)publishOptions deliveryOptions:(DeliveryOptions *)deliveryOptions response:(void(^)(MessageStatus *))responseBlock error:(void(^)(Fault *))errorBlock;
For sending only push notification, the article explains to use A) (deliveryOptions only), but I thought C)(deliveryOption + publishOption) is one for push notification. Unless publish options is set for a message, how do I set badge count, sound, etc?
FYI, I set options in following way, however, I tried to add, remove, change some of options to see if it works.
DeliveryOptions *deliveryOptions = [DeliveryOptions new];//[[DeliveryOptions alloc] init];
[deliveryOptions pushBroadcast:IOS];//ALL];
[deliveryOptions pushPolicy:PUSHONLY];
There are 2 mechanisms for delivering messages to devices:
Native push notifications - can be delivered to a device even when app is not running
Messages delivered via publish/subscribe messages - delivered to your app while it is running.
In your post you refer to the "subscribe" method which belongs to (2), yet you're talking about "push notifications" which is (1). Could you please clarify which mechanism you really need?
I see there’s difference between 1 and 2. Well backendless is little bit different from what I’ve used. Previous baas does have same subscribe/publish which actually send pushes to target channel regardless of app state. And besides, push notification is part of messaging service, it’s kind of confusing for me.
I presumed sending message with push option would send push regardless of app state - most of users would want this because there’s no way to notify user when app goes in background. Also if push is sent only to active users, then sender has to check if user is active or not: if not active, send with 1) otherwise send with 2).
Anyway my answer to your question is (1) native push notification.
Do I need to use push to device using below API for 1)?
If you look at my first question, I already tried that.
I tried again now, but it doesn’t work for channel that user created.
There’s no problem sending push notification to default channel.
Sending push notification to default channel from console or from iOS device works.
Sending push notification to user created channel from console does or from iOS device does not work.
“Backendless delivers messages marked as push notifications published to the channels to all devices registered with the channels. If no channels specified, Backendless registers the device with the “default” channel. If the call references a non-existing channel, Backendless creates the channel and registers the device with it. Registration expiration is a point in time (expressed as a timestamp) when the device registration should expire. Backendless removes the device registration at the specified time and device no longer receives published notifications.”
So, you can create the own channel, “typoSending” for example:
[backendless.messagingService registerDevice:@[@“typoSending”]];
and all devices, which have been registered for this channel, will get the push notifications.
Thanks for quick reply.
Now I get it. There’s bit of confusion though.
Before, I only called registerDeviceToken and subscribe, but channel name that I am subscribing, appears on the console. So I thought I’ve created channel which I am subscribing.
And besides, there’s no line of code uses registerDevice in the example, there’s only subscribe.
1). The method “subscribe” is used by publish/subscribe mechanism (2) - native push notification (1) don’t need it.
2). Yes - “registerDevice creates channel automatically registers creator as subscriber”.
If a send a push notification to one channel, and after the same message to another channel, the user suscribed to this channels will receive 2 push notifications?
In parse I can send 1 push notification and select some channels :
Sergey thanks for reply but in this link I cant see a way to send a single push notification for selected channels.
In web console I only can send a message to one channel, and after send the same message to another channel.
I have more than 1.000 deviceToken registered in all my channels (in backendless), but when I send a notification from web-console in any channel to iOS-Devices the push does not arrive.
Only if I send a push notification to a selected device the push notification works…
I am using Xcode 7.3.1 and iOS 9.3 target.
But I still thinking that is a web-console problem because all the process to suscribe to a channel from device, register the token-id in web-console is working perfectly.