Can I have multiple Push Providers in my app and how do I configure this?

If your app already has code in it for receiving messages from another push provider, the receiver code needs to either be removed from the app or be told to ignore messages from Xtremepush. Without this configuration, the pre-existing message receiver code could be sent a copy of any incoming Xtremepush push messages and attempt to handle the message as if it had come from its own push provider. This can lead to more than one message being displayed.

All Xtremepush push messages have been marked with a specific key-value pair, to let our SDK know that the message is from Xtremepush and should be handled by the SDK. This key-value marking of the message can also be used in the receiver code for your other push provider in order to detect Xtremepush messages and ignore them.

On Android the following function can be inserted into your push receiver or Intent Service code for your other push provider:

public boolean shouldIgnoreMessage(Intent intent, Context context) {
    try {
        if (intent == null)
            return false;
        String message = intent.getExtras().getString("message");
        if (message == null)
            return false;
        PushMessage pushMessage = ResponseParser.parsePushMessage(message, new WeakReference<>(context), false);
        return pushMessage != null;
    } catch (Exception e) {
        return false;
    }
}

The function returns true when the message has been parsed and confirmed as coming from Xtremepush. In this case, the message should be ignored by the other push provider receiver. If it is not a message from Xtremepush, the function will return a false value and the message should be handled normally. 

 

On iOS if you need to check  if a message has come from xtremepush so you can ignore it you could do the following:


- (void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo {
if ([userInfo objectForKey:@"xpush"] != nil) {
[XPush applicationDidReceiveRemoteNotification:userInfo]; }else { // Do you our own thing } }
Have more questions? Submit a request

0 Comments

Article is closed for comments.