正如他们网站上提到的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上订阅我的应用程序。
如果我忘记执行任何步骤,谁能告诉我。
最佳答案
终于我找到了路。现在正在工作。我从他们网站的教程中获得了代码。
所以我正在写步骤。
步骤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");
}