Support Topics Documentation Slack YouTube Blog

iOS to Android push notifications and visa versa

(George Ginis) #1

Suppose one device is running iOS and another is running Android. The headers for each platform are different in each case when sending push notifications. If one user (running iOS) is about to send a push notification to another user (running Android), how is this situation handled? Do we have to check for the recipient registration info and set the appropriate headers? Or maybe it is handled by the server and the headers are translated before the server sends out the notification? Please let me know how this situtation should be handled. Thank you in advance.

(Vyacheslav Vdovichenko) #2

You should merge iOS and Android headers in both apps. For example, for iOS:

-(void)publish {
    NSDictionary *publishHeaders = @{
                          @"android-content-text":@"Content text",
                          @"android-ticker-text":@"Ticker text"

    PublishOptions *publishOptions = [PublishOptions new];
    [publishOptions assignHeaders:publishHeaders];
    DeliveryOptions *deliveryOptions = [DeliveryOptions new];
    [deliveryOptions pushPolicy:PUSH_ONLY];
    [deliveryOptions pushBroadcast:FOR_ANDROID|FOR_IOS];
     response:^(MessageStatus *status) {
         NSLog(@"Message has been sent: %@", status);
     error:^(Fault *fault) {
         NSLog(@"Server reported an error: %@", fault);

(George Ginis) #3

Thank you for your quick response and for clarifying this for me.



(Vyacheslav Vdovichenko) #4

You can try our TestPushNotify sample (see in attachment). It has Objective-c & Swift targets. Load it with TestPushNotify.xcworkspace. (19.3MB)