Skip to content

Instantly share code, notes, and snippets.

@PoomSmart
Created May 31, 2015 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PoomSmart/8f7bf2eb92e8ebd44185 to your computer and use it in GitHub Desktop.
Save PoomSmart/8f7bf2eb92e8ebd44185 to your computer and use it in GitHub Desktop.
Fake Push Notifications for iOS 7+
#import <Foundation/Foundation.h>
// ApplePushService.framework
@interface APSMessage : NSObject
- (id)initWithTopic:(NSString *)topic userInfo:(NSDictionary *)userInfo;
@end
@interface APSIncomingMessage : APSMessage
@end
@interface SBRemoteNotificationServer : NSObject
+ (SBRemoteNotificationServer *)sharedInstance;
- (void)connection:(id /* APSConnection* */)connection didReceiveIncomingMessage:(APSIncomingMessage *)message;
@end
static void notifyUserWithMessageAndBundleIdentifier(NSString *message, NSString *bundleIdentifier)
{
NSDictionary *userInfo = @{ @"aps" : @{ @"alert" : message } };
// if an application returned by bundleIdentifier does not exist, the system will not push.
// nil userInfo causes system to crash.
APSIncomingMessage *message = [[%c(APSIncomingMessage) alloc] initWithTopic:bundleIdentifier userInfo:userInfo];
[[%c(SBRemoteNotificationServer) sharedInstance] connection:nil didReceiveIncomingMessage:message];
[message release];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment