開発端末のデバイストークン確認の方法
開発端末のデバイストークンの確認方法ですが、 GrowthPushのSDKの内部メソッドの呼び出しで取得が可能です。
開発用のコードです。リリースアプリには使用しないでください。
iOSの場合
NSLog(@"deviceToken: %@", [[[[GrowthPush class] performSelector:@selector(sharedInstance)] performSelector:@selector(client)] performSelector:@selector(token)]);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
while(true) {
sleep(1);
if([[[GrowthPush class] performSelector:@selector(sharedInstance)] performSelector:@selector(client)]) {
NSLog(@"deviceToken: %@", [[[[GrowthPush class] performSelector:@selector(sharedInstance)] performSelector:@selector(client)] performSelector:@selector(token)]);
return;
}
}
});
Androidの場合
if (GrowthPush.getInstance().getClient() != null) Log.i("DeviceToken", GrowthPush.getInstance().getClient().getToken());
実際に使う場合は、デバイストークンの読み込みが完了するまでの待ち処理として、下記のようなコードを使うことができます。
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
if (GrowthPush.getInstance().getClient() != null) {
Log.i("DeviceToken", GrowthPush.getInstance().getClient().getToken());
return;
}
}
}
}).start();