iOS小部件未刷新

时间:2018-03-26 13:44:48

标签: ios widget today-extension

我的应用程序有一个小部件,应显示最新消息。但是,当用户进入应用程序并刷新内容时,它始终显示新内容。我已经实现了widgetPerfomrUpdateWithComplationHandler和viewDidAppear来显示新内容。

我的应用注册了自己的推送通知。我需要在代码中实现什么,或者服务器端有问题吗?

这是我的代码:

-(void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self.articleTableView reloadData];
}
-(void)viewDidDisappear:(BOOL)animated{
    [self.articleEntitiesArray removeAllObjects];
    self.articleEntitiesArray = nil;
    [super viewDidDisappear:animated];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return kHeightCell;
}
- (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
    // Perform any setup necessary in order to update the view.
    // If an error is encountered, use NCUpdateResultFailed
    // If there's no update required, use NCUpdateResultNoData
    // If there's an update, use NCUpdateResultNewData

    [self fetchAndStoreContentsForList:nil completionHandler:^(NSError *error) {
    if(error != nil) {
        [self.articleTableView reloadData] ;
        completionHandler(NCUpdateResultNewData);
    }
    else {
        self.unableToLoadErrorLbl.hidden = YES;
        [self.activityIndicator stopAnimating];
        self.activityIndicator.hidesWhenStopped = true;
        completionHandler(NCUpdateResultNoData);
    }
    }];
}

1 个答案:

答案 0 :(得分:0)

糟糕的是,我弄清楚了我找不到的URL。