Ios 在某些情况下从应用程序向twitter发送消息

Ios 在某些情况下从应用程序向twitter发送消息,ios,objective-c,Ios,Objective C,在某些情况下,应用程序是否可以在twitter上发送消息而无需用户干预?例如,当电池充电低于10%时? 对不起,英语不好 您可以这样监控电池电量: UIDevice *device = [UIDevice currentDevice]; device.batteryMonitoringEnabled = YES; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(batteryChanged:) n

在某些情况下,应用程序是否可以在twitter上发送消息而无需用户干预?例如,当电池充电低于10%时?
对不起,英语不好

您可以这样监控电池电量:

UIDevice *device = [UIDevice currentDevice];
device.batteryMonitoringEnabled = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(batteryChanged:) name:@"UIDeviceBatteryLevelDidChangeNotification" object:device];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(batteryChanged:) name:@"UIDeviceBatteryStateDidChangeNotification" object:device];

// Your notification handler
- (void)batteryChanged:(NSNotification *)notification
{
    UIDevice *device = [UIDevice currentDevice];
    if(device.batteryLevel <= 10)
        [self twittBatteryLevel: device.batteryLevel];
}
UIDevice*device=[UIDevice currentDevice];
device.batteryMonitoringEnabled=是;
[[NSNotificationCenter defaultCenter]添加观察者:自选择器:@选择器(电池更改:)名称:@“UIDeviceBatteryLevel-DidChangeNotification”对象:设备];
[[NSNotificationCenter defaultCenter]添加观察者:自选择器:@选择器(电池更改:)名称:@“UIDeviceBatteryStateDidChangeNotification”对象:设备];
//您的通知处理程序
-(无效)电池更改:(NSNotification*)通知
{
UIDevice*设备=[UIDevice currentDevice];

如果(device.batteryLevel谢谢!但是你能代表用户发送无人值守的消息吗?他当然必须接受你的应用程序授权以它的名义twitt,但只有在设置应用程序twitter帐户时才可以发送消息?非常感谢!你真的帮了我很多忙!如果答案正确,请毫不犹豫地选择答案所以