So the first step obviously is to apply the polyfill globally using:
import {polyfill as polyfillFetch} from 'react-native-polyfill-globals/src/fetch'
polyfillFetch();
I put this in a shim.js
that is imported by the top-level index.js
.
The second step is to patch @dfinity/agent
to replace this line with:
this._fetch('' + new URL(`/api/v2/canister/${ecid.toText()}/call`, this._host), Object.assign(Object.assign({reactNative: {textStreaming: true}}, transformedRequest.request), { body })),
Note that {reactNative: {textStreaming: true}}
was added.
The last step is to patch react-native-fetch-api
and replace the “blob” in this line with “base64”.
Let me know if this works.