我正在尝试从iOS 10中的webview获取所有cookie,但是它不能返回完整的cookie列表,在iOS 11情况下,它可以完美运行。
对于iOS 11:
public class AFragment extends Fragment {
View view;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_a, container, false);
ButterKnife.bind(this, view);
//moved to onCreate() method
//setHasOptionsMenu(true);
//set toolbar as the default for the activity class if AppCompat
((AppCompatActivity) getActivity()).setSupportActionBar(/*your toolbar goes here*/);
//set toolbar is activity class is not AppCompat
getActivity().setActionBar(/*your toolbar goes here*/);
return view;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_a, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_a) {
//getFragmentManager().popBackStackImmediate();
}
return super.onOptionsItemSelected(item);
}
}
它可以完美工作并返回所有服务器cookie。
对于iOS 10:
var cookieStore = webView.Configuration.WebsiteDataStore.HttpCookieStore;
它不会返回所有cookie。
我正在使用WKWebView。我如何从WKWebView获取所有cookie。 ? 感谢您的帮助。