Reputation: 3387
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.
Upvotes: 0
Views: 713
Reputation: 3387
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");
}
Upvotes: 2
Reputation: 1
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.
Upvotes: 0