小编oph*_*ius的帖子

检索已获取的推送通知令牌

我们正在开发一个可以接收推送通知的应用.在我们的测试设备上,当系统提示我们发送通知时,我们点击了确定,但未能存储我们收到的令牌.(我们对服务器的请求未得到妥善处理,令牌未被我们存储在其他地方).

我们已尝试以下方法再次使用函数didRegisterForRemoteNotificationsWithDeviceToken触发(无效):

  • 完全删除该应用程序并重新安装
  • 在iPhone设置中关闭我们应用的通知

但是,我们不能让它再次"提示"我们,并且APN开发服务器似乎已经注册了所以我假设这就是为什么didRegisterForRemoteNotificationsWithDeviceToken不会再次触发.

最后我们无法获得新的令牌,我不知道如何检索已经注册的令牌.有谁知道如何检索已注册的令牌?

token push-notification ios

5
推荐指数
1
解决办法
4363
查看次数

MagicalRecord不保存数据

我正在尝试MagicalRecord的一些非常基本的实现,以获得它的悬念并遇到以下问题.

当我保存一个条目然后获取该类型的条目时,它将提供我刚刚保存的条目.但是,当我保存条目时,关闭应用程序,再次启动它,然后获取,它会变为空.

保存代码:

- (void)createTestTask{
    NSManagedObjectContext *localContext = [NSManagedObjectContext contextForCurrentThread];

    Task *task = [Task createInContext:localContext];
    task.tName = @"First Task";
    task.tDescription = @"First Task created with MagicalRecord. Huzzah!";


    NSError *error;
    [localContext save:&error];
    if (error != Nil) {
        NSLog(@"%@", error.description);
    }
}
Run Code Online (Sandbox Code Playgroud)

获取代码:(如果实际保存了任何内容,我想知道所有内容)

- (void) fetchTasks{
    NSArray *tasks = [Task findAll];
    NSLog(@"Found %d tasks", [tasks count]);
}
Run Code Online (Sandbox Code Playgroud)

我确信我在这里遗漏了一些东西,但在stackoverflow或我看过的教程中似乎找不到任何东西.

欢迎任何帮助.

ios magicalrecord

5
推荐指数
1
解决办法
3557
查看次数

横向模式UIView.center提供纵向模式坐标

我有一个应用程序,它以横向模式运行,我在手机上调试时以横向模式运行它.我从主视图控制器上的UIView中取出中心值,我需要将它放在屏幕中央,因为它是通用的,我需要它是可变的而不是设置为iPhone屏幕尺寸.

当我这样做并从view.center返回的CGPoint中读取x和y时,得到x = 170 y = 240

委托是我的应用程序中的一个视图控制器,中心功能是我想要移动到中心的对象之一.

- (void) center
{
    CGPoint center = ((UIViewController*)delegate).view.center;
    CGSize size = self.frame.size;
    double x = center.x - size.width/2 - location.x;
    double y = center.y - size.height/2 - location.y;

    [self _move:1.0 curve:UIViewAnimationCurveEaseInOut x:x y:y];
}

- (void)_move: (NSTimeInterval)duration
            curve:(int)curve x:(CGFloat)x y:(CGFloat)y
{
    // Setup the animation
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:duration];
    [UIView setAnimationCurve:curve];
    [UIView setAnimationBeginsFromCurrentState:YES];

    // The transform matrix
    CGAffineTransform transform = CGAffineTransformMakeTranslation(x, y);
    self.transform = transform;

    // Commit the changes
    [UIView commitAnimations]; …
Run Code Online (Sandbox Code Playgroud)

iphone uiview ios

1
推荐指数
1
解决办法
1675
查看次数

标签 统计

ios ×3

iphone ×1

magicalrecord ×1

push-notification ×1

token ×1

uiview ×1