Search code examples
iosapple-push-notificationspushwoosh

Integrating PushWoosh on iOS 7 not getting subscribed on pushwoosh


As Mentioned on Their Site 3 steps

Step 1 - Add Push NotificationsSDK to your project (Done)

Step 2 - In Info.plist add the following key Pushwoosh_APPID with your Pushwoosh id

Step 3 - Add below code in App delegate

#import "PushNotificationManager.h

- (void) onPushAccepted:(PushNotificationManager *)pushManager withNotification:(NSDictionary *)pushNotification {
    NSLog(@"Push notification received");
}

I did all these three simple steps but I am not being subscribed to my app on PushWoosh. Can Anyone tell me if I forget to do any steps.


Solution

  • Finally i found the way. Its working now. i got the code from tutorial of their site.

    So i am writing the steps.

    Step 1 - Add Push NotificationsSDK to your project

    Step 2 - In Info.plist add the following key Pushwoosh_APPID with your Pushwoosh id

    Step 3 - Add -ObjC and -all_load in other linker flags. (ex below).

    enter image description here

    Step 4 - Add below code in AppDelegate.h

     **#import "Pushwoosh/PushNotificationManager.h"**
    
    @interface AppDelegate : UIResponder <UIApplicationDelegate,**PushNotificationDelegate**>
    

    Step 5 - Add below code in AppDelegate.m

     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    

    {

    //Your Other Code
    
    [PushNotificationManager pushManager].delegate = self;
    
    [[PushNotificationManager pushManager] handlePushReceived:launchOptions];
    
    [[PushNotificationManager pushManager] sendAppOpen];
    
    [[PushNotificationManager pushManager] registerForPushNotifications];
    

    }

    Given Below Delegates for Push notifications

     - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [[PushNotificationManager pushManager] handlePushRegistration:deviceToken];
     }
    
      - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    [[PushNotificationManager pushManager] handlePushRegistrationFailure:error];
     }
    
     - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    [[PushNotificationManager pushManager] handlePushReceived:userInfo];
     }
    
     - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    NSDictionary *pushDict = [userInfo objectForKey:@"aps"];
    BOOL isSilentPush = [[pushDict objectForKey:@"content-available"] boolValue];
    
    if (isSilentPush) {
        NSLog(@"Silent push notification:%@", userInfo);
    
        //load content here
    
        // must call completionHandler
        completionHandler(UIBackgroundFetchResultNewData);
    }
    else {
        [[PushNotificationManager pushManager] handlePushReceived:userInfo];
    
        // must call completionHandler
        completionHandler(UIBackgroundFetchResultNoData);
    }
    }
    
    
     - (void) onPushAccepted:(PushNotificationManager *)pushManager withNotification:(NSDictionary *)pushNotification
      {
        NSLog(@"Push notification received");
    
      }