【问题标题】:Show the content of push notification in UIAlertView在 UIAlertView 中显示推送通知的内容
【发布时间】:2014-03-12 22:02:44
【问题描述】:

您好,我目前正在开发一个应用程序,我已在其中激活了推送通知。我使用 parse.com。到目前为止,我已经让它工作了,我可以发送通知并且设备接收它,我还在应用程序上获得了一个徽章。当您从通知进入应用程序时,我已经设置了一个 AlertView。但我不知道如何在 UIAlertView 中显示推送通知的文本。我还希望在您查看消息时徽章消失。这是我使用的代码:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
if (application.applicationState == UIApplicationStateInactive)
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Text" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];

    [alert show];
}
else if (application.applicationState == UIApplicationStateActive)
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Text" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];

    [alert show];
}
}

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

{
    NSDictionary * pushDictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

    if (pushDictionary)
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Text" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];

        [alert show];
    }
}

【问题讨论】:

标签: ios push-notification uialertview


【解决方案1】:

要处理推送通知并显示警报视图及其信息,请尝试在 appDelegate 中:

- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {     
   [PFPush handlePush:userInfo];  
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-05
    • 1970-01-01
    • 2018-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-29
    相关资源
    最近更新 更多