【问题标题】:message read or not iphone消息已读或未读 iphone
【发布时间】:2010-10-06 09:47:56
【问题描述】:

我如何检测收到的短信是否被用户读取,我正在使用 CTMessageCenter 标头也请帮助我..

并告诉我如何将我的应用程序连续置于后台......

【问题讨论】:

  • 这是两个问题。他们应该单独询问。此外,您没有提供足够的信息。最后,无法检测用户是否阅读过短信。以后请参考stackoverflow.com/questions/how-to-ask

标签: iphone sms message


【解决方案1】:

我认为没有任何方法可以让我们发现在非越狱中是否读取了消息...

【讨论】:

    【解决方案2】:

    是的,您可以阅读传入的消息并发送。在您的 main.m 中编写此代码并使用三个文件:CoreTelephony.h、CTMessage.h、CTMessageCenter.h 使用这种方式的一个问题是您无法在应用商店中提交您的应用。

    static void callback(CFNotificationCenterRef center, void *observer, NSString* name, const void *object, NSDictionary* info) {
        fprintf(stderr, "Notification intercepted: %s\n", [name UTF8String]);
        if([name isEqualToString:@"kCTMessageReceivedNotification"] && info)
        {
            NSNumber* messageType = [info valueForKey:@"kCTMessageTypeKey"];
            if([messageType isEqualToNumber:[NSNumber numberWithInt:1]])
            {
                NSNumber* messageID = [info valueForKey:@"kCTMessageIdKey"];
                CTMessageCenter* mc = [CTMessageCenter sharedMessageCenter];
                CTMessage* msg = [mc incomingMessageWithId:[messageID intValue]];
                NSObject<CTMessageAddress>* phonenumber = [msg sender];
    
                NSString *senderNumber = (NSString*)[phonenumber canonicalFormat];
                NSString *sender = (NSString*)[phonenumber encodedString];
                CTMessagePart* msgPart = [[msg items] objectAtIndex:0]; //for single-part msgs
                NSData *smsData = [msgPart data];
                NSString *smsText = [[NSString alloc] initWithData:smsData encoding:NSUTF8StringEncoding];
                fprintf(stderr, "SMS Message from %s / %s: \"%s\"\n",[senderNumber UTF8String],[sender UTF8String],[smsText UTF8String]);
            }
        }
        return;
    }
    
    
    int main(int argc, char **argv)
    {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    
        id ct = CTTelephonyCenterGetDefault();
        CTTelephonyCenterAddObserver(ct, NULL, callback, NULL, NULL, CFNotificationSuspensionBehaviorHold);
    
        // Start the run loop. Now we'll receive notifications.
        [[NSRunLoop currentRunLoop] run];
        NSLog(@"you are in main thread");
        [pool drain];
        printf("Unexpectedly back from CFRunLoopRun()!\n");
        [pool release];
    }
    

    【讨论】:

    • 感谢您的回复。但这是否可以通过使用公共框架来实现。
    • 没有这个私人信息,你不能在appstore上上传你的应用程序,他们会拒绝这个。Apple不提供访问应用程序中的私人信息
    猜你喜欢
    • 1970-01-01
    • 2021-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-06
    • 2013-10-04
    • 2018-05-11
    相关资源
    最近更新 更多