Difference between revisions of "SBRemoteNotificationServer"

From iPhone Development Wiki
Jump to: navigation, search
(Faking push notification: Updated for iOS 8.)
m (Faking push notification)
Line 7: Line 7:
 
NSString *topic = @"com.yourcompany.appname";
 
NSString *topic = @"com.yourcompany.appname";
  
// pre iOS 8
+
// pre iOS 7
 
[[%c(SBRemoteNotificationServer) sharedInstance] connection:nil didReceiveMessageForTopic:topic userInfo:userInfo];
 
[[%c(SBRemoteNotificationServer) sharedInstance] connection:nil didReceiveMessageForTopic:topic userInfo:userInfo];
  
// iOS 8
+
// iOS 7+
 
APSIncomingMessage *message = [[%c(APSIncomingMessage) alloc] initWithTopic:topic userInfo:userInfo];
 
APSIncomingMessage *message = [[%c(APSIncomingMessage) alloc] initWithTopic:topic userInfo:userInfo];
 
[[%c(SBRemoteNotificationServer) sharedInstance] connection:nil didReceiveIncomingMessage:message];
 
[[%c(SBRemoteNotificationServer) sharedInstance] connection:nil didReceiveIncomingMessage:message];

Revision as of 16:03, 31 May 2015

SBRemoteNotificationServer is a singleton class that receives Apple push notifications.

Faking push notification

Push notification may be faked locally these ways:

NSDictionary *userInfo = @{ @"aps" : @{ @"badge" = @5, @"alert" : @"hi" } };
NSString *topic = @"com.yourcompany.appname";

// pre iOS 7
[[%c(SBRemoteNotificationServer) sharedInstance] connection:nil didReceiveMessageForTopic:topic userInfo:userInfo];

// iOS 7+
APSIncomingMessage *message = [[%c(APSIncomingMessage) alloc] initWithTopic:topic userInfo:userInfo];
[[%c(SBRemoteNotificationServer) sharedInstance] connection:nil didReceiveIncomingMessage:message];
[message release];

References