twa-dev / SDK

npm package for TWA SDK
https://codesandbox.io/s/sdk-kj5961
MIT License
238 stars 21 forks source link

switchInlineQuery can't work on ios, Android is normal. #29

Open elsemk opened 6 days ago

elsemk commented 6 days ago

"@twa-dev/sdk": "^7.10.1" ios 17 mywebapp:https://t.me/testElse_bot/whatTelegram After registering, go to the lucky draw page and click Invite for Spins,No response at ios。 `import React, { memo } from 'react'; import { RightOutline } from 'antd-mobile-icons'; import WebApp from '@twa-dev/sdk'; import { useMemoizedFn, useRequest } from 'ahooks'; import { useNavigate } from 'umi';

import InvitationBg from '@/assets/game-invite-bg.png'; import ShareLinkIcon from '@/assets/share-link-icon.png'; import ShareCopyIcon from '@/assets/share-copy-icon.png'; import DownloadIcon from '@/assets/invite-download-icon.png'; import InviteBtnBg from '@/assets/invite-btn-bg.png'; import useTelegramInfo from '@/models/useTelegramInfo'; import { copyText } from '@/utils/tools'; import useUserInfo from '@/models/useUserInfo'; import api from '@/services';

import './index.less';

export default memo(() => { const { userInfo } = useUserInfo(); const tmaInfo = useTelegramInfo();

const navigate = useNavigate();

const { data } = useRequest(() => { return api.common.getInviteList({ current: 1, size: 10 }); });

const handleInvite = useMemoizedFn(() => { if (tmaInfo?.initDataUnsafe?.user?.id) { // @ts-ignore WebApp.switchInlineQuery(tmaInfo.initDataUnsafe.user.id, [ 'users', 'groups', 'channels', 'bots', ]); } });

const handleCopy = useMemoizedFn(() => { copyText(https://t.me/testElse_bot/whatTelegram?startapp=${userInfo?.id}); });

const handleDownload = useMemoizedFn(() => { WebApp.openLink( https://www.iboloup.com/home?shareID=${userInfo?.id}&telegram_id=${tmaInfo?.initDataUnsafe?.user?.id}, ); }); return (

Invite for Spins
  </div>
  <div className="c-mi__user" onClick={() => navigate('/invitation')}>
    <div className="c-mi__user-text">
      Invited users : {data?.total || 0}
    </div>
    <RightOutline className="c-mi__user-icon" color="#fff" />
  </div>
  <div className="c-mi__button" onClick={handleDownload}>
    <div className="c-mi__button-bg">
      <img src={InviteBtnBg} />
    </div>
    <div className="c-mi__button-text">
      DownloadAPP for 1 free Spins <img src={DownloadIcon} />
    </div>
  </div>
</div>

); }); `