My App licsense check not work

Can anyone help me on this bug?

I try shell command of:

forge install --environment development --license active --upgrade

Code:

const context = await view.getContext();

const [isLicensed, setIsLicensed] = useState(false);

useEffect(() => {
    const fetchContext = async () => {
      try {
        const ctx = context || await view.getContext();
        setContext(ctx);
        console.log('Fetched context:', ctx);
        // Check if license is active
        if (ctx && ctx.license && ctx.license.isActive === true) {
          setIsLicensed(true);
          console.log('App is licensed' + ctx.license);
        } else {
          setIsLicensed(false);
          console.log('App is not licensed' + ctx.license);
        }
      } catch (err) {
        console.error('Error fetching context:', err);
        setIsLicensed(false);
      }
    };
    fetchContext();
  }, []);

{/* License Modal - displayed when app is not licensed */}
      {/* This modal appears with an overlay to prevent any interaction with the app */}
      {!isLicensed && (
        <div style={{
          position: 'fixed',
          top: 0,
          left: 0,
          right: 0,
          bottom: 0,
          backgroundColor: 'rgba(0, 0, 0, 0.5)',
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'center',
          zIndex: 9999
        }}>
          <Modal show={true} centered backdrop="static" keyboard={false}>
            <Modal.Header style={{ backgroundColor: '#f8d7da', borderColor: '#f5c6cb' }}>
              <Modal.Title style={{ color: '#721c24' }}>
                {t('licenseRequired') || 'License Required'}
              </Modal.Title>
            </Modal.Header>
            <Modal.Body style={{ padding: '24px' }}>
              <div style={{ textAlign: 'center' }}>
                <p style={{ fontSize: '16px', marginBottom: '16px', color: '#333' }}>
                  {t('appNotLicensed') || 'This app is not currently licensed for your Jira site.'}
                </p>
                <p style={{ fontSize: '14px', color: '#666', marginBottom: '24px' }}>
                  {t('contactAdminForLicense') || 'Please contact your Jira administrator to activate the license for the Timesheet app.'}
                </p>
                <div style={{ 
                  backgroundColor: '#f8d7da', 
                  border: '1px solid #f5c6cb', 
                  padding: '12px', 
                  borderRadius: '4px',
                  color: '#721c24'
                }}>
                  <p style={{ margin: '0' }}>
                    {t('licenseInactive') || 'License Status: Inactive'}
                  </p>
                </div>
              </div>
            </Modal.Body>
            <Modal.Footer style={{ backgroundColor: '#f8f9fa', borderTop: '1px solid #dee2e6' }}>
              <p style={{ margin: 0, fontSize: '12px', color: '#6c757d' }}>
                {t('licenseInfoNeeded') || 'License information: Contact your system administrator'}
              </p>
            </Modal.Footer>
          </Modal>
        </div>
      )}


image

if (ctx.license && !ctx.license.active) {
    setIsLicensed(false);
}

license is null in all cases.

Is there a “licensing” key in your manifest.yml?

app:
  id: ari:cloud:ecosystem::app/12345678-90ab-cdef-1234-2840465f3b84
  name: Forge Demo App
  licensing:
    enabled: true

Yes there is

licensing:
    enabled: true

MS Github Copilot says license is not work in development environment. So I got it work:

const [isLicensed, setIsLicensed] = useState(false);

  useEffect(() => {
    const fetchContext = async () => {
      try {
        const ctx = context || await view.getContext();
        
        // In development environments, license is null - treat as licensed for testing
        const isDevelopment = ctx?.environmentType === 'DEVELOPMENT';
        const isActiveLicense = ctx?.license?.isActive === true;
        
        if (isDevelopment || isActiveLicense) {
          setIsLicensed(true);
          console.log('App is licensed (dev mode: ' + isDevelopment + ', active license: ' + isActiveLicense + ')');
        } else {
          setIsLicensed(false);
          console.log('App is not licensed - license:', ctx?.license);
        }
      } catch (err) {
        console.error('Error fetching context: ', err);
        setIsLicensed(false);
      }
    };
    fetchContext();
  }, []);