Integrating PushWoosh on iOS 7 not getting subscribed on pushwoosh

跟風遠走 提交于 2019-12-12 02:52:26

问题


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.


回答1:


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).

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");

  }



回答2:


If your device is connected to the Internet via WiFi, and messages don’t get through to the device, please make sure APNs ports are not blocked by your firewall. Push providers, iOS devices, and Mac computers are often behind firewalls. To send notifications, you will need to allow inbound and outbound TCP packets over port 2195. Devices and computers connecting to the push service over Wi-Fi will need to allow inbound and outbound TCP packets over port 5223.

The IP address range for the push service is subject to change; the expectation is that providers will connect by hostname rather than IP address. The push service uses a load balancing scheme that yields a different IP address for the same hostname. However, the entire 17.0.0.0/8 address block is assigned to Apple, so you can specify that range in your firewall rules.



来源:https://stackoverflow.com/questions/25182023/integrating-pushwoosh-on-ios-7-not-getting-subscribed-on-pushwoosh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!