1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PWAAdvent Calendar 2019

Day 12

OneSignalで管理画面からUserを削除してしまった際にRestAPIで400が出続ける際の対応法

Last updated at Posted at 2019-12-12

PWA Advent Calendar 2019 12日目の記事です。

PWAというよりもOneSignalがメインの記事です。
OneSignalでUserを削除した際の対応方法の話です。

結論

cookieを消す

はじめに

OneSignalで管理画面からUserを削除して、その後RestAPIで独自タグを設定しようとすると
400 Bad Request: Put "https://onesignal.com/api/v1/player/${playerid}"
こんな感じの400エラーが出る。

試しに別の端末から同じ操作をしたら普通に登録できた。
OneSignalで管理画面からUserを削除するとどうも同じplayeridからリクエストを受け付けてくれないっぽい。

色々考えたて、OneSignalの公式ドキュメントを読むと
Audience

When does the OneSignal Player Id change?
OneSignal makes a best effort to keep the same Player Id on all devices that are assigned. Some circumstances that may cause it to change:

WEB PUSH - When the user clears their cookie data for your site.

ANDROID - If the user has opted out of the Google Advertising Id, uninstalls the app and re-installs.

iOS - If the user does not have any other apps installed that have your IFV (identifierForVendor), then uninstalling your app and re-installing it, will give them a new Player Id.

The IFV is used to keep the ID the same after a full re-install, but only if the user has another one of your apps installed.

cookieを消せばいいとのこと。

そしたらば、400 Bad Request: Put "https://onesignal.com/api/v1/player/${playerid}"
が出ずに独自タグ設定できるようになりました。

管理画面からUserを削除するのは基本的にやらないほうがいいですね。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?