0

I am pretty new to iOS dev. I started building a BLE app a month back and it works fine in foreground and background and there is nothing wrong with BLE connection as such. I restored my phone last week. After restarting the moment I tried running my app in my iPhone. It started crashing. The code was breaking on this line.

[self.manager retrievePeripherals:[NSArray arrayWithObject:(id)peripheral.UUID]];

with a SIGABRT signal. I installed endomondo and tried pairing my sensor with it. It asked me to enable ble and I tapped yes on the dialog and the belt paired. After that I checked my app and it started working fine too. What I think is that since before making my own app, I had endomondo installed so something was enabled already for my app to work fine. I cant really understand what needs to be done to enable my app for ble operations without having any other app to do this for me. Help me fix this. Do we need to set something else to enable ble rather than just enabling bluetooth from settings?

4

1 に答える 1

0

私の記憶が正しければ、iOS 6.x の特定のバージョンは、周辺機器の UUID プロパティに関しておかしな結果を返すことがありました。正当な値であるはずなのに、nil として返されることがありました。私のアプリケーションの1つで、これらのケースに対して次のような回避策を使用することになりました。

if (aPeripheral.UUID != nil)
{
    [centralManager retrievePeripherals:[NSArray arrayWithObject:(id)aPeripheral.UUID]];
}
else
{
    [self centralManager:centralManager didRetrievePeripherals:[NSArray arrayWithObject:aPeripheral]];
}

これにより、ペリフェラルがデリゲート メソッドに直接渡され、取得手順が回避されました。このようにすると、アプリケーションは確実に動作するように見えます。iOS 6.0 の新しいポイント リリースにアップグレードした後、これは不要になったと思います。

于 2013-06-08T15:58:39.117 に答える