正如在他们的站点上提到的,3步
步骤1-向项目中添加Push NotificationsSDK (已完成) 步骤2-在Info.plist中使用Pushwoosh id添加以下Pushwoosh_APPID键 步骤3-在App委托中添加下面的代码
#import "PushNotificationManager.h
- (void) onPushAccepted:(PushNotificationManager *)pushManager withNotification:(NSDictionary *)pushNotification {
NSLog(@"Push notification received");
}我做了这三个简单的步骤,但我并没有在PushWoosh上订阅我的应用程序。有人能告诉我如果我忘记做任何步骤。
发布于 2014-08-09 10:45:54
终于找到了路。现在起作用了。我从他们网站的教程中得到了代码。
所以我在写步骤。
步骤1-将Push NotificationsSDK添加到项目中
步骤2-在Info.plist中使用Pushwoosh id添加以下Pushwoosh_APPID键
步骤3-在其他链接器标志中添加-ObjC和-all_load。(除下文外)。

步骤4-在AppDelegate.h中添加下面的代码
**#import "Pushwoosh/PushNotificationManager.h"**
@interface AppDelegate : UIResponder <UIApplicationDelegate,**PushNotificationDelegate**>步骤5-在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];}
提供以下推送通知的代表
- (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");
}发布于 2014-08-08 05:45:37
如果您的设备通过WiFi连接到互联网,并且消息无法通过该设备,请确保APN端口不会被防火墙阻塞。推送提供商、iOS设备和Mac计算机通常都在防火墙后面。要发送通知,需要允许端口2195上的入站和出站TCP数据包。通过will连接到推送服务的设备和计算机将需要允许端口5223上的入站和出站TCP数据包。
推送服务的IP地址范围可能会发生变化;预计提供者将使用主机名而不是IP地址进行连接。push服务使用负载平衡方案,为同一主机名生成不同的IP地址。但是,整个17.0.0.0/8地址块分配给Apple,因此您可以在防火墙规则中指定该范围。
https://stackoverflow.com/questions/25182023
复制相似问题