Simulator can neither subscribe nor receive push notifications.

To integrate Pushwoosh into your application follow these simple steps:

1. Add Pushwoosh.framework to your project. You should copy it into your project folder and either drag and drop it into your project or use a dependency manager.

target 'MyApp' do
	pod 'Pushwoosh'
end
github "Pushwoosh/pushwoosh-ios-sdk"

2. Add libz and libstdc++ to the project.

  • go to Target section
  • open "Build Phases" tab
  • open "Link Binaries With Libraries"
  • click on "+" button
  • search "libz.tbd"
  • click on add button
  • Repeat the same process for libstdc++.tbd library.

3. In your Info.plist add the Pushwoosh_APPID key with your Pushwoosh Application ID string value

4. Add following code to your AppDelegate:

import Pushwoosh
import UserNotifications

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, PushNotificationDelegate {

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
    //  lots of initialization code
  
    // set custom delegate for push handling, in our case AppDelegate
    PushNotificationManager.push().delegate = self
    
    // set default Pushwoosh delegate for iOS10 foreground push handling
    if #available(iOS 10.0, *) {
      UNUserNotificationCenter.current().delegate = PushNotificationManager.push().notificationCenterDelegate
    }
    
    // track application open statistics
    PushNotificationManager.push().sendAppOpen()
    
    // register for push notifications!
    PushNotificationManager.push().registerForPushNotifications()
    
    return true
  }
  
  func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    PushNotificationManager.push().handlePushRegistration(deviceToken as Data!)
  }
  
  func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
    PushNotificationManager.push().handlePushRegistrationFailure(error)
  }
  
  func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    PushNotificationManager.push().handlePushReceived(userInfo)
    completionHandler(UIBackgroundFetchResult.noData)
  }
}
#import <Pushwoosh/PushNotificationManager.h>
#import <UserNotifications/UserNotifications.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    //lots of initialization code

    // set custom delegate for push handling, in our case AppDelegate
    PushNotificationManager * pushManager = [PushNotificationManager pushManager];
    pushManager.delegate = self;
     
		// set default Pushwoosh delegate for iOS10 foreground push handling
		[UNUserNotificationCenter currentNotificationCenter].delegate = [PushNotificationManager pushManager].notificationCenterDelegate;
     
    // track application open statistics
    [[PushNotificationManager pushManager] sendAppOpen];
     
    // register for push notifications!
    [[PushNotificationManager pushManager] registerForPushNotifications];
 
    return YES;
}

// system push notification registration success callback, delegate to pushManager
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [[PushNotificationManager pushManager] handlePushRegistration:deviceToken];
}
 
// system push notification registration error callback, delegate to pushManager
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    [[PushNotificationManager pushManager] handlePushRegistrationFailure:error];
}
 
// system push notifications callback, delegate to pushManager
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
    [[PushNotificationManager pushManager] handlePushReceived:userInfo];
    completionHandler(UIBackgroundFetchResultNoData);
}

@end

To handle push notifications add the following function to your PushNotificationDelegate

// this event is fired when the push is received in the app
func onPushReceived(_ pushManager: PushNotificationManager!, withNotification pushNotification: [AnyHashable : Any]!, onStart: Bool) {
		print("Push notification received: \(pushNotification)")
    // shows a push is received. Implement passive reaction to a push, such as UI update or data download.
}

// this event is fired when user clicks on notification
func onPushAccepted(_ pushManager: PushNotificationManager!, withNotification pushNotification: [AnyHashable : Any]!, onStart: Bool) {
		print("Push notification accepted: \(pushNotification)")
    // shows a user tapped the notification. Implement user interaction, such as showing push details
}
// this event is fired when the push is received in the app
- (void)onPushReceived:(PushNotificationManager *)pushManager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
    NSLog(@"Push notification received");
    // shows a push is received. Implement passive reaction to a push, such as UI update or data download.
}

// this event is fired when user clicks on notification
- (void)onPushAccepted:(PushNotificationManager *)pushManager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
    NSLog(@"Push notification accepted");
    // shows a user tapped the notification. Implement user interaction, such as showing push details
}

5. Enable Push Notifications in the Capabilities section.

6. Enable "Remote notifications" for Background Modes in the Capabilities section.

7. To take advantage of automatic test device registration make sure your app is compatible with Test Devices as outlined here:
http://docs.pushwoosh.com/docs/test-devices#ios

That’s it!

iOS SDK